Redigera

Dela via


SemaphoreAcl.TryOpenExisting(String, SemaphoreRights, Semaphore) Method

Definition

Tries to open a specified named semaphore, if it already exists, applies the desired access rights, and returns a value that indicates whether the operation succeeded.

public:
 static bool TryOpenExisting(System::String ^ name, System::Security::AccessControl::SemaphoreRights rights, [Runtime::InteropServices::Out] System::Threading::Semaphore ^ % result);
public static bool TryOpenExisting (string name, System.Security.AccessControl.SemaphoreRights rights, out System.Threading.Semaphore? result);
static member TryOpenExisting : string * System.Security.AccessControl.SemaphoreRights * Semaphore -> bool
Public Shared Function TryOpenExisting (name As String, rights As SemaphoreRights, ByRef result As Semaphore) As Boolean

Parameters

name
String

The name of the semaphore to be opened. If it's prefixed by "Global", it refers to a machine-wide semaphore. If it's prefixed by "Local", or doesn't have a prefix, it refers to a session-wide semaphore. Both prefix and name are case-sensitive.

rights
SemaphoreRights

The desired access rights to apply to the returned semaphore.

result
Semaphore

When this method returns true, contains an object that represents the named semaphore if the call succeeded, or null otherwise. This parameter is treated as uninitialized.

Returns

true if the named semaphore was opened successfully; otherwise, false.

Exceptions

name is null

name is an empty string.

A Win32 error occurred.

The named semaphore exists, but the user does not have the security access required to use it.

Applies to