Changeset 15973 for branches/2522_RefactorPluginInfrastructure/HeuristicLab.DebugEngine/3.3/DebugEngine.cs
- Timestamp:
- 06/28/18 11:13:37 (6 years ago)
- Location:
- branches/2522_RefactorPluginInfrastructure
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2522_RefactorPluginInfrastructure
- Property svn:ignore
-
old new 24 24 protoc.exe 25 25 obj 26 .vs
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/2522_RefactorPluginInfrastructure/HeuristicLab.DebugEngine/3.3/DebugEngine.cs
r12012 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 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 ae.FlattenAndHandle(new[] { typeof(OperationCanceledException) }, e => OnExceptionOccurred(e)); 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) { 321 if (ex is OperationCanceledException) throw ex; 309 } catch (Exception ex) { 310 if (ex is OperationCanceledException) throw; 322 311 else throw new OperatorExecutionException(operation.Operator, ex); 323 312 }
Note: See TracChangeset
for help on using the changeset viewer.