Changeset 13349 for branches/Async/HeuristicLab.Algorithms.DataAnalysis/3.4/FixedDataAnalysisAlgorithm.cs
- Timestamp:
- 11/23/15 21:18:26 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Async/HeuristicLab.Algorithms.DataAnalysis/3.4/FixedDataAnalysisAlgorithm.cs
r12012 r13349 70 70 } 71 71 72 public override void Start() {73 base.Start();72 public override async Task StartAsync(CancellationToken cancellationToken) { 73 await base.StartAsync(cancellationToken); 74 74 var cancellationTokenSource = new CancellationTokenSource(); 75 75 76 76 OnStarted(); 77 Task task = Task.Factory.StartNew(Run, cancellationTokenSource.Token, cancellationTokenSource.Token); 78 task.ContinueWith(t => { 79 try { 80 t.Wait(); 81 } 82 catch (AggregateException ex) { 77 using (var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationTokenSource.Token, cancellationToken)) { 78 Task task = Task.Factory.StartNew(Run, cts.Token, cts.Token); 79 await task.ContinueWith(t => { 83 80 try { 84 ex.Flatten().Handle(x => x is OperationCanceledException);81 t.Wait(); 85 82 } 86 catch (AggregateException remaining) { 87 if (remaining.InnerExceptions.Count == 1) OnExceptionOccurred(remaining.InnerExceptions[0]); 88 else OnExceptionOccurred(remaining); 83 catch (AggregateException ex) { 84 try { 85 ex.Flatten().Handle(x => x is OperationCanceledException); 86 } 87 catch (AggregateException remaining) { 88 if (remaining.InnerExceptions.Count == 1) OnExceptionOccurred(remaining.InnerExceptions[0]); 89 else OnExceptionOccurred(remaining); 90 } 89 91 } 90 }91 cancellationTokenSource.Dispose();92 cancellationTokenSource = null;93 OnStopped();94 } );92 cancellationTokenSource.Dispose(); 93 cancellationTokenSource = null; 94 OnStopped(); 95 }); 96 } 95 97 } 96 98 private void Run(object state) {
Note: See TracChangeset
for help on using the changeset viewer.