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

◆ OpenExistingWorker()

static OpenExistingResult System.Threading.Mutex.OpenExistingWorker ( string name,
out Mutex result )
inlinestaticprivate

Definition at line 70 of file Mutex.cs.

71 {
72 if (name == null)
73 {
74 throw new ArgumentNullException("name");
75 }
76 if (name.Length == 0)
77 {
78 throw new ArgumentException(SR.Argument_EmptyName, "name");
79 }
80 result = null;
81 SafeWaitHandle safeWaitHandle = Interop.Kernel32.OpenMutex(34603009u, inheritHandle: false, name);
82 if (safeWaitHandle.IsInvalid)
83 {
84 int lastPInvokeError = Marshal.GetLastPInvokeError();
85 if (2 == lastPInvokeError || 123 == lastPInvokeError)
86 {
87 return OpenExistingResult.NameNotFound;
88 }
89 if (3 == lastPInvokeError)
90 {
91 return OpenExistingResult.PathNotFound;
92 }
93 if (6 == lastPInvokeError)
94 {
95 return OpenExistingResult.NameInvalid;
96 }
97 throw Win32Marshal.GetExceptionForWin32Error(lastPInvokeError, name);
98 }
99 result = new Mutex(safeWaitHandle);
100 return OpenExistingResult.Success;
101 }
static SafeWaitHandle OpenMutex(uint desiredAccess, bool inheritHandle, string name)
static Exception GetExceptionForWin32Error(int errorCode, string path="")

References System.Threading.Mutex.Mutex(), System.SR.Argument_EmptyName, System.IO.Win32Marshal.GetExceptionForWin32Error(), System.Runtime.InteropServices.Marshal.GetLastPInvokeError(), Microsoft.Win32.SafeHandles.SafeHandleZeroOrMinusOneIsInvalid.IsInvalid, and Interop.Kernel32.OpenMutex().

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