Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Flush()

unsafe void System.IO.MemoryMappedFiles.MemoryMappedView.Flush ( UIntPtr capacity)
inline

Definition at line 94 of file MemoryMappedView.cs.

95 {
96 byte* pointer = null;
97 try
98 {
100 if (global::Interop.Kernel32.FlushViewOfFile((IntPtr)pointer, capacity))
101 {
102 return;
103 }
104 int lastPInvokeError = Marshal.GetLastPInvokeError();
105 if (lastPInvokeError != 33)
106 {
107 throw System.IO.Win32Marshal.GetExceptionForWin32Error(lastPInvokeError);
108 }
109 SpinWait spinWait = default(SpinWait);
110 for (int i = 0; i < 15; i++)
111 {
112 int millisecondsTimeout = 1 << i;
114 for (int j = 0; j < 20; j++)
115 {
116 if (global::Interop.Kernel32.FlushViewOfFile((IntPtr)pointer, capacity))
117 {
118 return;
119 }
120 lastPInvokeError = Marshal.GetLastPInvokeError();
121 if (lastPInvokeError != 33)
122 {
123 throw System.IO.Win32Marshal.GetExceptionForWin32Error(lastPInvokeError);
124 }
125 spinWait.SpinOnce();
126 }
127 }
128 throw System.IO.Win32Marshal.GetExceptionForWin32Error(lastPInvokeError);
129 }
130 finally
131 {
132 if (pointer != null)
133 {
135 }
136 }
137 }
readonly SafeMemoryMappedViewHandle _viewHandle
static Exception GetExceptionForWin32Error(int errorCode, string path="")
unsafe void AcquirePointer(ref byte *pointer)
Definition SafeBuffer.cs:58
static void Sleep(int millisecondsTimeout)
Definition Thread.cs:658

References System.IO.MemoryMappedFiles.MemoryMappedView._viewHandle, System.Runtime.InteropServices.SafeBuffer.AcquirePointer(), System.capacity, System.IO.Win32Marshal.GetExceptionForWin32Error(), System.Runtime.InteropServices.Marshal.GetLastPInvokeError(), System.millisecondsTimeout, System.pointer, System.Runtime.InteropServices.SafeBuffer.ReleasePointer(), System.Threading.Thread.Sleep(), and System.Threading.SpinWait.SpinOnce().

Referenced by System.IO.MemoryMappedFiles.MemoryMappedViewAccessor.Flush(), and System.IO.MemoryMappedFiles.MemoryMappedViewStream.Flush().