/// <summary> /// Releases the unmanaged and managed resources. /// </summary> public void Dispose() { if (state.Switch(1, 0)) { OnDisposing(); Dispose(true); state.Switch(2); OnDisposed(); GC.SuppressFinalize(this); } }