protected void CreateHandles(long capacity) { if (NativeStream.Length > capacity) { capacity = NativeStream.Length; } Handle = MemoryMappedFile.CreateFromFile( NativeStream, null, capacity, MemoryMappedFileAccess.ReadWrite, null, HandleInheritability.None, true ); HeaderView = Handle.CreateViewAccessor(0, HeaderSize); StreamCapacity = capacity; Cache = new ViewCache(Handle, StreamCapacity); }
private void DisposeViews() { if (Cache != null) { Cache.Dispose(); Cache = null; } if (HeaderView != null) { // https://connect.microsoft.com/VisualStudio/feedback/details/552859/memorymappedviewaccessor-flush-throws-ioexception // HeaderView.Dispose(); HeaderView.SafeMemoryMappedViewHandle.Dispose(); HeaderView = null; } if (Handle != null) { Handle.Dispose(); Handle = null; } }
private void DisposeViews() { if (Cache != null) { Cache.Dispose(); Cache = null; } if (HeaderView != null) { // https://connect.microsoft.com/VisualStudio/feedback/details/552859/memorymappedviewaccessor-flush-throws-ioexception // HeaderView.Dispose(); HeaderView.SafeMemoryMappedViewHandle.Dispose(); HeaderView = null; } if (Handle != null) { Handle.Dispose(); Handle = null; } }
protected void CreateHandles(long capacity) { if (NativeStream.Length > capacity) capacity = NativeStream.Length; Handle = MemoryMappedFile.CreateFromFile( NativeStream, null, capacity, MemoryMappedFileAccess.ReadWrite, null, HandleInheritability.None, true ); HeaderView = Handle.CreateViewAccessor(0, HeaderSize); StreamCapacity = capacity; Cache = new ViewCache(Handle, StreamCapacity); }
public StreamRange(StreamRef stream, ViewCache.CacheEntry cacheEntry, long offset, uint size) { Stream = stream; CacheEntry = cacheEntry; View = null; Offset = offset; Size = size; Buffer = cacheEntry.Buffer; IsDisposed = false; unchecked { Pointer = cacheEntry.Pointer + cacheEntry.PointerOffset; Pointer += (offset - cacheEntry.Offset); } }