protected virtual void Dispose(bool disposing, CloseExState closeState) { // All calls below should already be idempotent. try { if (disposing) { ICloseEx icloseEx = WrappedStream as ICloseEx; if (icloseEx != null) { icloseEx.CloseEx(closeState); } else { WrappedStream.Close(); } } } finally { base.Dispose(disposing); } }
protected virtual void Dispose(bool disposing, CloseExState closeState) { try { if (Interlocked.Increment(ref _Disposed) == 1) { if (disposing) { ICloseEx icloseEx = WrappedStream as ICloseEx; if (icloseEx != null) { icloseEx.CloseEx(closeState); } else { WrappedStream.Close(); } if (m_CacheDestroy) { if (m_IsStrictCacheErrors) { m_Cache.Remove(m_Key); } else { m_Cache.TryRemove(m_Key); } } else { if (m_IsStrictCacheErrors) { m_Cache.Update(m_Key, m_Expires, m_LastModified, m_LastSynchronized, m_MaxStale, m_EntryMetadata, m_SystemMetadata); } else { m_Cache.TryUpdate(m_Key, m_Expires, m_LastModified, m_LastSynchronized, m_MaxStale, m_EntryMetadata, m_SystemMetadata); } } } } } finally { base.Dispose(disposing); } }
protected virtual void Dispose(bool disposing, CloseExState closeState) { // All below calls should already be idempotent try { if (disposing) { try { ICloseEx icloseEx = WrappedStream as ICloseEx; if (icloseEx != null) { icloseEx.CloseEx(closeState); } else { WrappedStream.Close(); } } finally { // Notify the wirte stream on a partial response if did not see EOF on read if (!m_SeenReadEOF) { closeState |= CloseExState.Abort; } // // We don't want to touch m_ShadowStreamIsDead because Close() can be called from other thread while IO is in progress. // We assume that all streams used by this class are thread safe on Close(). // m_ShadowStreamIsDead = true; if (m_ShadowStream is ICloseEx) { ((ICloseEx)m_ShadowStream).CloseEx(closeState); } else { m_ShadowStream.Close(); } } } } finally { base.Dispose(disposing); } }