System.Threading.Semaphore.OpenExisting Method

Opens the specified named semaphore, if it already exists.

Syntax

public static Semaphore OpenExisting (string name)

Parameters

name
The name of the system semaphore to open.

Returns

An object that represents the named system semaphore.

Remarks

The erload:System.Threading.Semaphore.OpenExisting method tries to open the specified 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.

This method overload is equivalent to calling the Semaphore.OpenExisting(string, System.Security.AccessControl.SemaphoreRights) method overload and specifying System.Security.AccessControl.SemaphoreRights.Synchronize and System.Security.AccessControl.SemaphoreRights.Modify rights, combined by using the bitwise OR operation.

Specifying the System.Security.AccessControl.SemaphoreRights.Synchronize flag allows a thread to enter the semaphore, and specifying the System.Security.AccessControl.SemaphoreRights.Modify flag allows a thread to call the erload:System.Threading.Semaphore.Release method.

Requirements

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