Changeset 15292 for stable/HeuristicLab.DebugEngine
- Timestamp:
- 07/28/17 16:47:42 (8 years ago)
- Location:
- stable
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
stable ¶
- Property svn:mergeinfo changed
/branches/Async (added) merged: 13329,13349,13354-13355,13401,15065,15190,15204,15212,15215-15216,15232,15280-15281,15284,15286 /trunk/sources merged: 15287
- Property svn:mergeinfo changed
-
TabularUnified stable/HeuristicLab.DebugEngine/3.3/DebugEngine.cs ¶
r14186 r15292 23 23 using System.Linq; 24 24 using System.Threading; 25 using System.Threading.Tasks;26 25 using HeuristicLab.Common; 27 26 using HeuristicLab.Core; … … 161 160 while (skipStackOperations && !(CurrentOperation is IAtomicOperation) && CanContinue) 162 161 ProcessNextOperation(true, cancellationTokenSource.Token); 163 } 164 catch (Exception ex) { 162 } catch (Exception ex) { 165 163 OnExceptionOccurred(ex); 166 164 } … … 174 172 } 175 173 176 public override void Start( ) {177 base.Start( );178 cancellationTokenSource = new CancellationTokenSource();174 public override void Start(CancellationToken cancellationToken) { 175 base.Start(cancellationToken); 176 cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); 179 177 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) { 186 try { 187 ex.Flatten().Handle(x => x is OperationCanceledException); 188 } 189 catch (AggregateException remaining) { 190 if (remaining.InnerExceptions.Count == 1) OnExceptionOccurred(remaining.InnerExceptions[0]); 191 else OnExceptionOccurred(remaining); 192 } 193 } 194 cancellationTokenSource.Dispose(); 195 cancellationTokenSource = null; 196 197 if (stopPending) ExecutionStack.Clear(); 198 if (stopPending || !CanContinue) OnStopped(); 199 else OnPaused(); 200 }); 201 } 202 178 179 try { 180 Run(cancellationTokenSource.Token); 181 } catch (OperationCanceledException) { 182 } catch (AggregateException ae) { 183 OnExceptionOccurred(ae.InnerExceptions.SingleOrDefault() ?? ae); 184 } catch (Exception e) { 185 OnExceptionOccurred(e); 186 } 187 188 cancellationTokenSource.Dispose(); 189 cancellationTokenSource = null; 190 if (stopPending) ExecutionStack.Clear(); 191 if (stopPending || !CanContinue) OnStopped(); 192 else OnPaused(); 193 } 203 194 protected override void OnStarted() { 204 195 Log.LogMessage("Engine started"); … … 250 241 ProcessNextOperation(false, cancellationToken); 251 242 cancellationToken.ThrowIfCancellationRequested(); 252 } 253 finally { 243 } finally { 254 244 timer.Stop(); 255 245 ExecutionTime += DateTime.UtcNow - lastUpdateTime; … … 317 307 } 318 308 CurrentOperation = null; 319 } 320 catch (Exception ex) { 309 } catch (Exception ex) { 321 310 if (ex is OperationCanceledException) throw ex; 322 311 else throw new OperatorExecutionException(operation.Operator, ex);
Note: See TracChangeset
for help on using the changeset viewer.