public void Dispose() { if (Interlocked.Exchange(ref _memoryMappedViewAccessor, null) is var memoryMappedViewAccessor) { _buffer.DangerousRelease(); memoryMappedViewAccessor.Dispose(); } Interlocked.Exchange(ref _memoryMappedFile, null)?.Dispose(); }