- Timestamp:
- 11/26/12 11:12:57 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Clients.Hive/3.3/HiveClient.cs
r8914 r8939 294 294 cancellationToken.ThrowIfCancellationRequested(); 295 295 296 // upload tasks 297 refreshableJob.Progress.Status = "Uploading tasks..."; 298 299 var tasks = new List<TS.Task>(); 300 foreach (HiveTask hiveTask in refreshableJob.HiveTasks) { 301 var task = TS.Task.Factory.StartNew((hj) => { 302 UploadTaskWithChildren(refreshableJob.Progress, (HiveTask)hj, null, resourceIds, jobCount, totalJobCount, configFilePlugin.Id, refreshableJob.Job.Id, refreshableJob.Log, refreshableJob.Job.IsPrivileged, cancellationToken); 303 }, hiveTask); 304 task.ContinueWith((x) => refreshableJob.Log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted); 305 tasks.Add(task); 306 } 307 TS.Task.WaitAll(tasks.ToArray()); 308 } 309 finally { 296 310 refreshableJob.RefreshAutomatically = true; 297 311 refreshableJob.StartResultPolling(); 298 299 // upload tasks300 refreshableJob.Progress.Status = "Uploading tasks...";301 302 var tasks = new List<TS.Task>();303 foreach (HiveTask hiveTask in refreshableJob.HiveTasks) {304 tasks.Add(TS.Task.Factory.StartNew((hj) => {305 UploadTaskWithChildren(refreshableJob.Progress, (HiveTask)hj, null, resourceIds, jobCount, totalJobCount, configFilePlugin.Id, refreshableJob.Job.Id, refreshableJob.Log, refreshableJob.Job.IsPrivileged, cancellationToken);306 }, hiveTask)307 .ContinueWith((x) => refreshableJob.Log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted));308 }309 try {310 TS.Task.WaitAll(tasks.ToArray());311 }312 catch (AggregateException ae) {313 if (!ae.InnerExceptions.All(e => e is TaskCanceledException)) throw ae; // for some reason the WaitAll throws a AggregateException containg a TaskCanceledException. i don't know where it comes from, however the tasks all finish properly, so for now just ignore it314 }315 312 refreshableJob.Job.Modified = false; 316 }317 finally {318 313 refreshableJob.IsProgressing = false; 319 314 refreshableJob.Progress.Finish(); … … 405 400 var tasks = new List<TS.Task>(); 406 401 foreach (HiveTask child in hiveTask.ChildHiveTasks) { 407 tasks.Add(TS.Task.Factory.StartNew((tuple) => {402 var task = TS.Task.Factory.StartNew((tuple) => { 408 403 var arguments = (Tuple<HiveTask, HiveTask>)tuple; 409 404 UploadTaskWithChildren(progress, arguments.Item1, arguments.Item2, groups, taskCount, totalJobCount, configPluginId, jobId, log, isPrivileged, cancellationToken); 410 }, new Tuple<HiveTask, HiveTask>(child, hiveTask)) 411 .ContinueWith((x) => log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted)); 405 }, new Tuple<HiveTask, HiveTask>(child, hiveTask)); 406 task.ContinueWith((x) => log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted); 407 tasks.Add(task); 412 408 } 413 409 taskUploadSemaphore.Release(); semaphoreReleased = true; // the semaphore has to be release before waitall! 414 try { 415 TS.Task.WaitAll(tasks.ToArray()); 416 } 417 catch (AggregateException ae) { 418 if (!ae.InnerExceptions.All(e => e is TaskCanceledException)) throw ae; // for some reason the WaitAll throws a AggregateException containg a TaskCanceledException. i don't know where it comes from, however the tasks all finish properly, so for now just ignore it 419 } 410 TS.Task.WaitAll(tasks.ToArray()); 420 411 } 421 412 finally {
Note: See TracChangeset
for help on using the changeset viewer.