/// <summary> /// Unblocks waiting threads and ends the execution lifetime. /// </summary> /// <exception cref="ObjectDisposedException"> /// The object is disposed. /// </exception> public void End() { using (var controlToken = StateControl.Enter()) { RejectIfDisposed(); if (IsAlive) { EndOfLifeEvent.Set(); IsAlive = false; } } }
/// <summary> /// Releases all resources consumed by the current <see cref="ServiceExecutionLifetime" />. /// </summary> /// <param name="disposing"> /// A value indicating whether or not managed resources should be released. /// </param> protected override void Dispose(Boolean disposing) { try { if (disposing) { using (var controlToken = StateControl.Enter()) { if (IsAlive) { EndOfLifeEvent.Set(); IsAlive = false; } EndOfLifeEvent.Dispose(); } } } finally { base.Dispose(disposing); } }