System.Threading.Semaphore.OpenExisting Method

Opens the specified named semaphore, if it already exists, with the desired security access.

Syntax

public static Semaphore OpenExisting (string name, System.Security.AccessControl.SemaphoreRights rights)

Parameters

name
The name of the system semaphore to open.
rights
A bitwise combination of the enumeration values that represent the desired security access.

Returns

An object that represents the named system semaphore.

Remarks

The rights parameter must include the System.Security.AccessControl.SemaphoreRights.Synchronize flag to allow threads to enter the semaphore, and the System.Security.AccessControl.SemaphoreRights.Modify flag to allow threads to call the erload:System.Threading.Semaphore.Release method.

The erload:System.Threading.Semaphore.OpenExisting method tries to open an existing named semaphore. If the system semaphore does not exist, this method throws an exception instead of creating the system semaphore. To create the system semaphore when it does not already exist, use one of the Semaphore.#ctor(int, int, string) constructors that has a name parameter.

Multiple calls to this method that use the same value for name do not necessarily return the same System.Threading.Semaphore object, even though the objects that are returned represent the same named system semaphore.

Requirements

Namespace: System.Threading
Assembly: System (in System.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0