Changeset 13349 for branches/Async/HeuristicLab.DebugEngine
- Timestamp:
- 11/23/15 21:18:26 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Async/HeuristicLab.DebugEngine/3.3/DebugEngine.cs
r12012 r13349 174 174 } 175 175 176 public override void Start() {177 base.Start();176 public override async Task StartAsync(CancellationToken cancellationToken) { 177 await base.StartAsync(cancellationToken); 178 178 cancellationTokenSource = new CancellationTokenSource(); 179 179 stopPending = false; 180 Task task = Task.Factory.StartNew(Run, cancellationTokenSource.Token, cancellationTokenSource.Token); 181 task.ContinueWith(t => { 182 try { 183 t.Wait(); 184 } 185 catch (AggregateException ex) { 180 using (var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationTokenSource.Token, cancellationToken)) { 181 Task task = Task.Factory.StartNew(Run, cts.Token, cts.Token); 182 await task.ContinueWith(t => { 186 183 try { 187 ex.Flatten().Handle(x => x is OperationCanceledException);184 t.Wait(); 188 185 } 189 catch (AggregateException remaining) { 190 if (remaining.InnerExceptions.Count == 1) OnExceptionOccurred(remaining.InnerExceptions[0]); 191 else OnExceptionOccurred(remaining); 186 catch (AggregateException ex) { 187 try { 188 ex.Flatten().Handle(x => x is OperationCanceledException); 189 } 190 catch (AggregateException remaining) { 191 if (remaining.InnerExceptions.Count == 1) OnExceptionOccurred(remaining.InnerExceptions[0]); 192 else OnExceptionOccurred(remaining); 193 } 192 194 } 193 }194 cancellationTokenSource.Dispose();195 cancellationTokenSource = null; 196 197 if (stopPending) ExecutionStack.Clear();198 if (stopPending || !CanContinue) OnStopped();199 else OnPaused();200 } );195 cancellationTokenSource.Dispose(); 196 cancellationTokenSource = null; 197 198 if (stopPending) ExecutionStack.Clear(); 199 if (stopPending || !CanContinue) OnStopped(); 200 else OnPaused(); 201 }); 202 } 201 203 } 202 204
Note: See TracChangeset
for help on using the changeset viewer.