Exemplo n.º 1
0
        public void Dispose()
        {
            Disposed = true;
            GC.SuppressFinalize(this);
            if (_readHandle != null)
            {
                _readHandle.Close();
            }
            _handle.Close();
            if (_nativeOverlapped != null)
            {
                Marshal.FreeHGlobal((IntPtr)_nativeOverlapped);
                _nativeOverlapped = null;
            }
            if (_segments != null)
            {
                Marshal.FreeHGlobal((IntPtr)_segments);
                _segments = null;
            }

            if (_manualResetEvent != null)
            {
                _manualResetEvent.Dispose();
            }

            if (DeleteOnClose)
            {
                File.Delete(_filename);
            }
        }
Exemplo n.º 2
0
        public void Dispose()
        {
            Disposed = true;
            GC.SuppressFinalize(this);
            if (_readHandle != null)
            {
                _readHandle.Close();
            }
            _handle.Close();
            if (_nativeOverlapped != null)
            {
                Marshal.FreeHGlobal((IntPtr)_nativeOverlapped);
                _nativeOverlapped = null;
            }
            if (_segments != null)
            {
                Marshal.FreeHGlobal((IntPtr)_segments);
                _segments = null;
            }

            if (DeleteOnClose)
            {
                try
                {
                    File.Delete(_filename);
                }
                catch (Exception)
                {
                    // if we can't delete, nothing that we can do here.
                }
            }
        }
Exemplo n.º 3
0
        private void EnsureSegmentsSize(byte *[] pages)
        {
            if (_segmentsSize >= pages.Length + 1)
            {
                return;
            }

            _segmentsSize = (int)Utils.NearestPowerOfTwo(pages.Length + 1);

            if (_segments != null)
            {
                Marshal.FreeHGlobal((IntPtr)_segments);
            }

            _segments = (FileSegmentElement *)(Marshal.AllocHGlobal(_segmentsSize * sizeof(FileSegmentElement)));
        }
Exemplo n.º 4
0
        public void Dispose()
        {
            Disposed = true;
            GC.SuppressFinalize(this);
            if (_readHandle != null)
                _readHandle.Close();
            _handle.Close();
            if (_nativeOverlapped != null)
            {
                Marshal.FreeHGlobal((IntPtr) _nativeOverlapped);
                _nativeOverlapped = null;
            }
            if (_segments != null)
            {
                Marshal.FreeHGlobal((IntPtr) _segments);
                _segments = null;
            }

            if (DeleteOnClose)
            {
                try
                {
                    File.Delete(_filename);
                }
                catch (Exception)
                {
                    // if we can't delete, nothing that we can do here.
                }
            }
        }
Exemplo n.º 5
0
        private void EnsureSegmentsSize(IntPtr[] pages)
        {
            if (_segmentsSize >= pages.Length + 1)
                return;

            _segmentsSize = (int) Utils.NearestPowerOfTwo(pages.Length + 1);

            if (_segments != null)
                Marshal.FreeHGlobal((IntPtr) _segments);

            _segments = (FileSegmentElement*) (Marshal.AllocHGlobal(_segmentsSize*sizeof (FileSegmentElement)));
        }
Exemplo n.º 6
0
 private static extern bool WriteFileGather(
     SafeFileHandle hFile,
     FileSegmentElement *aSegmentArray,
     uint nNumberOfBytesToWrite,
     IntPtr lpReserved,
     NativeOverlapped *lpOverlapped);
Exemplo n.º 7
0
		public void Dispose()
		{
			Disposed = true;
			GC.SuppressFinalize(this);
			if (_readHandle != null)
				_readHandle.Close();
			_handle.Close();
			if (_nativeOverlapped != null)
			{
				Marshal.FreeHGlobal((IntPtr) _nativeOverlapped);
				_nativeOverlapped = null;
			}
			if (_segments != null)
			{
				Marshal.FreeHGlobal((IntPtr) _segments);
				_segments = null;
			}

			if (DeleteOnClose)
			{
				File.Delete(_filename);
			}
		}