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

◆ CreateMutexCore()

void System.Threading.Mutex.CreateMutexCore ( bool initiallyOwned,
string name,
out bool createdNew )
inlineprivate

Definition at line 52 of file Mutex.cs.

53 {
54 uint flags = (initiallyOwned ? 1u : 0u);
55 SafeWaitHandle safeWaitHandle = Interop.Kernel32.CreateMutexEx(IntPtr.Zero, name, flags, 34603009u);
56 int lastPInvokeError = Marshal.GetLastPInvokeError();
57 if (safeWaitHandle.IsInvalid)
58 {
59 safeWaitHandle.SetHandleAsInvalid();
60 if (lastPInvokeError == 6)
61 {
62 throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name));
63 }
64 throw Win32Marshal.GetExceptionForWin32Error(lastPInvokeError, name);
65 }
66 createdNew = lastPInvokeError != 183;
67 base.SafeWaitHandle = safeWaitHandle;
68 }
static SafeWaitHandle CreateMutexEx(IntPtr lpMutexAttributes, string name, uint flags, uint desiredAccess)
static Exception GetExceptionForWin32Error(int errorCode, string path="")

References Interop.Kernel32.CreateMutexEx(), System.SR.Format(), System.IO.Win32Marshal.GetExceptionForWin32Error(), System.Runtime.InteropServices.Marshal.GetLastPInvokeError(), Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid.IsInvalid, System.Runtime.InteropServices.SafeHandle.SetHandleAsInvalid(), System.SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, and System.IntPtr.Zero.

Referenced by System.Threading.Mutex.Mutex(), System.Threading.Mutex.Mutex(), System.Threading.Mutex.Mutex(), and System.Threading.Mutex.Mutex().