/// <summary> /// Performs the actual releasing of managed and unmanaged resources. /// Most usage should instead call Dispose(), which will call Dispose(true) for you /// and will suppress redundant finalization. /// </summary> /// <param name="releaseManaged">Indicates whether to release managed resources. /// This should only be called with true, except from the finalizer which should call Dispose(false).</param> protected virtual void Dispose(bool releaseManaged) { if (!m_WeAreDisposed) { m_WeAreDisposed = true; // Only Dispose stuff once if (releaseManaged) { // Free managed resources here (normal Dispose() stuff, which should itself call Dispose(true)) // Other objects may be referenced in this case // We create a ProgressMonitorStack in our constructor, so we must release it here m_ProgressMonitors.Dispose(); } // Free native resources here (alloc's, etc) // May be called from within the finalizer, so don't reference other objects here } }