CreateSemaphore (kernel32)
Last changed: -65.215.1.13

.
Summary

C# Signature:

[DllImport("kernel32.dll", SetLastError=true)]
private static extern IntPtr CreateSemaphore(ref SECURITY_ATTRIBUTES securityAttributes, int initialCount, int maximumCount, string name);

[DllImport("kernel32.dll", SetLastError=true)]
private static extern IntPtr CreateSemaphore(
     IntPtr lpSemaphoreAttributes,
     int lInitialCount,
     int lMaximumCount,
     string lpName);

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Remember to specify an appropriate name prefix.

Sample Code:

See SECURITY_ATTRIBUTES for a sample of creating a semaphore with a NULL DACL.

Alternative Managed API:

System.Threading.CreateSemaphore system.threading.semaphore on MSDN

Documentation