Semaphore.TryOpenExisting Method (String, Semaphore)
Opens the specified named semaphore, if it already exists, and returns a value that indicates whether the operation succeeded.
Assembly: System (in System.dll)
[SecurityPermissionAttribute(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)] public static bool TryOpenExisting( string name, out Semaphore result )
The name of the system semaphore to open.
Return ValueType: System.Boolean
true if the named semaphore was opened successfully; otherwise, false.
If the named semaphore does not exist, this method does not create it. To create the system semaphore when it does not already exist, use one of the Semaphore constructors that has a name parameter.
If you are uncertain whether a named semaphore exists, use this method overload instead of the OpenExisting(String) method overload, which throws an exception if the semaphore does not exist.
This method overload is equivalent to calling the TryOpenExisting method overload and specifying SemaphoreRights.Synchronize and SemaphoreRights.Modify rights, combined by using the bitwise OR operation. Specifying the SemaphoreRights.Synchronize flag allows a thread to enter the semaphore, and specifying the SemaphoreRights.Modify flag allows a thread to call the Release method.
Available since 8
Available since 4.5
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Available since 8.1