protected void EndComputation() { Contract.Requires( this.State == ComputationState.Running || this.State == ComputationState.Aborted); lock (this.syncRoot) { switch (this.state) { case ComputationState.Running: this.state = ComputationState.Finished; this.OnFinished(EventArgs.Empty); break; case ComputationState.PendingAbortion: this.state = ComputationState.Aborted; this.OnAborted(EventArgs.Empty); break; default: throw new InvalidOperationException(); } this.Services.CancelManager.ResetCancel(); this.OnStateChanged(EventArgs.Empty); } }
private void EndComputation() { Debug.Assert( State == ComputationState.Running || State == ComputationState.PendingAbortion); lock (SyncRoot) { switch (_state) { case ComputationState.Running: _state = ComputationState.Finished; OnFinished(EventArgs.Empty); break; case ComputationState.PendingAbortion: _state = ComputationState.Aborted; OnAborted(EventArgs.Empty); break; default: throw new InvalidOperationException(); } Services.CancelManager.ResetCancel(); OnStateChanged(EventArgs.Empty); } }
public static void AssertAlgorithmState( [NotNull] AlgorithmBase algorithm, ComputationState state = ComputationState.NotRunning) { Assert.IsNotNull(algorithm.SyncRoot); Assert.AreEqual(state, algorithm.State); }
protected void BeginComputation() { Contract.Requires(this.State == ComputationState.NotRunning); lock (this.syncRoot) { this.state = ComputationState.Running; this.Services.CancelManager.ResetCancel(); this.OnStarted(EventArgs.Empty); this.OnStateChanged(EventArgs.Empty); } }
public static void AssertAlgorithmState <TGraph>( [NotNull] AlgorithmBase <TGraph> algorithm, [NotNull] TGraph treatedGraph, ComputationState state = ComputationState.NotRunning) { Assert.IsNotNull(treatedGraph); Assert.AreSame(treatedGraph, algorithm.VisitedGraph); Assert.IsNotNull(algorithm.Services); Assert.IsNotNull(algorithm.SyncRoot); Assert.AreEqual(state, algorithm.State); }
private void BeginComputation() { Debug.Assert(State == ComputationState.NotRunning); lock (SyncRoot) { _state = ComputationState.Running; Services.CancelManager.ResetCancel(); OnStarted(EventArgs.Empty); OnStateChanged(EventArgs.Empty); } }
protected void BeginComputation() { lock ( syncRoot ) { //if ( state != ComputationState.NotRunning ) // throw new InvalidOperationException(); state = ComputationState.Running; cancelling = 0; OnStarted( EventArgs.Empty ); OnStateChanged( EventArgs.Empty ); } }
protected void BeginComputation() { lock ( syncRoot ) { //if ( state != ComputationState.NotRunning ) // throw new InvalidOperationException(); state = ComputationState.Running; cancelling = 0; OnStarted(EventArgs.Empty); OnStateChanged(EventArgs.Empty); } }
protected void BeginComputation() { lock (this.syncRoot) { if (this.state != ComputationState.NotRunning) { throw new InvalidOperationException(); } this.state = ComputationState.Running; this.cancelling = 0; this.OnStarted(EventArgs.Empty); this.OnStateChanged(EventArgs.Empty); } }
protected void BeginComputation() { lock (this.syncRoot) { if (this.state != ComputationState.NotRunning) { throw new InvalidOperationException(); } this.state = ComputationState.Running; this.Services.CancelManager.ResetCancel(); this.OnStarted(EventArgs.Empty); this.OnStateChanged(EventArgs.Empty); } }
public virtual void Abort() { bool raise = false; lock ( syncRoot ) { if ( state == ComputationState.Running ) { state = ComputationState.PendingAbortion; System.Threading.Interlocked.Increment( ref cancelling ); raise = true; } } if ( raise ) OnStateChanged( EventArgs.Empty ); }
private void BeginComputation() { Debug.Assert( State == ComputationState.NotRunning || State == ComputationState.Finished || State == ComputationState.Aborted); lock (SyncRoot) { _state = ComputationState.Running; _cancelling = 0; OnStarted(EventArgs.Empty); OnStateChanged(EventArgs.Empty); } }
public virtual void Abort() { bool raise = false; lock (this.syncRoot) { if (this.state == ComputationState.Running) { this.state = ComputationState.PendingAbortion; System.Threading.Interlocked.Increment(ref this.cancelling); raise = true; } } if (raise) { this.OnStateChanged(EventArgs.Empty); } }
public void Abort() { bool raise = false; lock (this.syncRoot) { if (this.state == ComputationState.Running) { this.state = ComputationState.PendingAbortion; this.Services.CancelManager.Cancel(); raise = true; } } if (raise) { this.OnStateChanged(EventArgs.Empty); } }
public virtual void Abort() { bool raise = false; lock (_syncRoot) { if (_state == ComputationState.Running) { _state = ComputationState.PendingAbortion; Interlocked.Increment(ref _cancelling); raise = true; } } if (raise) { OnStateChanged(EventArgs.Empty); } }
protected void EndComputation() { lock (this.syncRoot) { switch (this.state) { case ComputationState.Running: this.state = ComputationState.Finished; this.OnFinished(EventArgs.Empty); break; case ComputationState.PendingAbortion: this.state = ComputationState.Aborted; this.OnAborted(EventArgs.Empty); break; default: throw new InvalidOperationException(); } this.cancelling = 0; this.OnStateChanged(EventArgs.Empty); } }
protected void EndComputation() { lock ( syncRoot ) { switch ( state ) { case ComputationState.Running: state = ComputationState.Finished; OnFinished( EventArgs.Empty ); break; case ComputationState.PendingAbortion: state = ComputationState.Aborted; OnAborted( EventArgs.Empty ); break; default: throw new InvalidOperationException(); } cancelling = 0; OnStateChanged( EventArgs.Empty ); } }