/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { if (IsDisposing) { return; } IsDisposing = true; IsCycleDone.Wait(); IsCycleDone.Dispose(); }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="alsoManaged"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> private void Dispose(bool alsoManaged) { lock (SyncRoot) { if (IsDisposed) { return; } IsDisposed = true; DelayEvent?.Dispose(); } }
/// <inheritdoc /> public void Dispose() { lock (_syncRoot) { if (_isDisposed) { return; } _isDisposed = true; _delayEvent?.Dispose(); } }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="alsoManaged"> /// <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> private void Dispose(bool alsoManaged) { if (!IsDisposed) { if (alsoManaged) { Destroy(); WaitForReadyEvent.Dispose(); } IsDisposed = true; } }
/// <inheritdoc /> public void Dispose() { lock (SyncLock) { if (IsDisposed) { return; } IsDisposed = true; Destroy(); WaitForReadyEvent.Dispose(); } }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="alsoManaged"> /// <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> private void Dispose(bool alsoManaged) { lock (SyncLock) { if (IsDisposed) { return; } IsDisposed = true; Destroy(); WaitForReadyEvent.Dispose(); } }
/// <inheritdoc /> public void Dispose() { lock (SyncRoot) { if (IsDisposed) { return; } IsDisposed = true; DelayEvent?.Dispose(); DelayTimer?.Dispose(); DelayStopwatch.Stop(); } }
/// <summary> /// Runs the timer cycle. /// </summary> /// <param name="state">The state.</param> private void RunTimerCycle(object state) { // Skip running this cycle if we are already in the middle of one if (IsCycleDone.IsInProgress) { return; } try { // Start a cycle by signaling it IsCycleDone.Begin(); // Call the configured timer callback TimerCallback(); } finally { if (HasRequestedStop == false) { // Finalize the cycle IsCycleDone.Complete(); } else { // Prevent a new cycle from being queued ThreadingTimer?.Change(Timeout.Infinite, Timeout.Infinite); FormsTimer?.Stop(); DispatcherTimer?.Stop(); // Handle the dispose process. ThreadingTimer?.Dispose(); FormsTimer?.Dispose(); // Remove references ThreadingTimer = null; FormsTimer = null; DispatcherTimer = null; // Complete the cycle and dispose of it IsCycleDone.Complete(); IsCycleDone.Dispose(); } } }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="alsoManaged"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> private void Dispose(bool alsoManaged) { if (IsDisposed) { return; } if (alsoManaged) { IsCancellationPending.Value = true; // Causes the playback loop to exit DriverCallbackEvent.Set(); // causes the WaitOne to exit PlaybackFinished.Wait(); // waits for the playback loop to finish DriverCallbackEvent.Dispose(); PlaybackFinished.Dispose(); } IsDisposed = true; }