示例#1
0
        public override void Sync(long totalUnsynced)
        {
            if (DisposeOnceRunner.Disposed)
            {
                ThrowAlreadyDisposedException();
            }

            if ((_fileAttributes & Win32NativeFileAttributes.Temporary) == Win32NativeFileAttributes.Temporary ||
                (_fileAttributes & Win32NativeFileAttributes.DeleteOnClose) == Win32NativeFileAttributes.DeleteOnClose)
            {
                return;
            }

            using (var metric = Options.IoMetrics.MeterIoRate(FileName.FullPath, IoMetrics.MeterType.DataSync, 0))
            {
                metric.IncrementSize(totalUnsynced);
                metric.SetFileSize(_totalAllocationSize);

                if (Win32MemoryMapNativeMethods.FlushFileBuffers(_handle) == false)
                {
                    var lastWin32Error = Marshal.GetLastWin32Error();
                    throw new Win32Exception($"Unable to flush file buffers on {FileName}",
                                             new Win32Exception(lastWin32Error));
                }
            }
        }
示例#2
0
 public override void Sync()
 {
     if (Win32MemoryMapNativeMethods.FlushFileBuffers(_handle) == false)
     {
         throw new Win32Exception();
     }
 }