/// <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> protected virtual void Dispose(bool alsoManaged) { lock (SyncLock) { if (m_IsDisposed) { return; } if (alsoManaged) { // Dispose managed state (managed objects). } // Free unmanaged resources (unmanaged objects) and override a finalizer below. using (Locker.AcquireWriterLock()) { Deallocate(); } // set large fields to null. Locker.Dispose(); Locker = null; m_IsDisposed = true; } }
/// <inheritdoc /> public void Dispose() { if (_isDisposed) { return; } _isDisposed = true; _locker?.Dispose(); _locker = null; }
/// <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; } IsDisposed = true; Locker?.Dispose(); Locker = null; }
/// <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) { Locker?.Dispose(); } Locker = null; IsDisposed = true; } }
/// <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) { IsDisposed = true; if (alsoManaged) { Clear(); Locker.Dispose(); } Locker = null; } }
/// <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 (DisposeLock) { if (IsDisposed) { return; } Clear(); Locker?.Dispose(); Marshal.FreeHGlobal(Buffer); Buffer = IntPtr.Zero; m_Length = 0; Locker = null; IsDisposed = true; } }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> public void Dispose() { using (Locker.AcquireWriterLock()) { while (PoolBlocks.Count > 0) { var block = PoolBlocks.Dequeue(); block.Dispose(); } for (var i = PlaybackBlocks.Count - 1; i >= 0; i--) { var block = PlaybackBlocks[i]; PlaybackBlocks.RemoveAt(i); block.Dispose(); } } Locker.Dispose(); Locker = null; }