protected override void Dispose(bool disposing) { if (_headers != null) { foreach (LocalStreamHeader header in _headers.Values) { if (header.Stream != null) { try { header.Stream.Reset(); #if UNMANAGEDSTREAM FSourceStreamManager.Close(header.StreamID); #else header.Stream.Close(); #endif } catch { // ignore exceptions here, the stream is disposed and we don't care } header.Stream = null; } } _headers.Dispose(); _headers = null; } base.Dispose(disposing); }
public void Deallocate(StreamID streamID) { // Deallocates the given stream in the source stream manager, and removes the header and local cache for it locally, without flushing LocalStreamHeader header; if (_headers.TryGetValue(streamID, out header)) { if (header.Stream != null) { header.Stream.Reset(); #if UNMANAGEDSTREAM FSourceStreamManager.Close(header.StreamID); #else header.Stream.Close(); #endif header.Stream = null; } _sourceStreamManager.Deallocate(header.StreamID); _headers.Remove(header.StreamID); header.Dispose(); } else { _sourceStreamManager.Deallocate(streamID); } }
public void Release(StreamID streamID) { // Ensures that the given local cache is flushed and closes the stream obtained from the source stream manager LocalStreamHeader header; if (_headers.TryGetValue(streamID, out header)) { if (header.Stream != null) { header.Stream.Flush(); #if UNMANAGEDSTREAM FSourceStreamManager.Close(AStreamID); #else header.Stream.Close(); #endif header.Stream = null; } _headers.Remove(header.StreamID); header.Dispose(); } }