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

◆ CreateSemaphoreCore()

void System.Threading.Semaphore.CreateSemaphoreCore ( int initialCount,
int maximumCount,
string name,
out bool createdNew )
inlineprivate

Definition at line 76 of file Semaphore.cs.

77 {
78 SafeWaitHandle safeWaitHandle = Interop.Kernel32.CreateSemaphoreEx(IntPtr.Zero, initialCount, maximumCount, name, 0u, 34603010u);
79 int lastPInvokeError = Marshal.GetLastPInvokeError();
80 if (safeWaitHandle.IsInvalid)
81 {
82 if (!string.IsNullOrEmpty(name) && lastPInvokeError == 6)
83 {
84 throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name));
85 }
87 }
88 createdNew = lastPInvokeError != 183;
89 base.SafeWaitHandle = safeWaitHandle;
90 }
static SafeWaitHandle CreateSemaphoreEx(IntPtr lpSecurityAttributes, int initialCount, int maximumCount, string name, uint flags, uint desiredAccess)
static Exception GetExceptionForLastWin32Error(string path="")

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

Referenced by System.Threading.Semaphore.Semaphore().