语言

SemaphoreAcl.TryOpenExisting(String, SemaphoreRights, Semaphore) 方法

定义

尝试打开指定的命名信号灯(如果已存在),应用所需的访问权限,并返回一个值,该值指示作是否成功。

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);
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

参数

name
String

要打开的信号灯的名称。 如果前缀为“Global”,则表示计算机范围的信号灯。 如果前缀为“Local”,或没有前缀,则表示会话范围的信号灯。 前缀和名称都区分大小写。

rights
SemaphoreRights

要应用于返回信号灯的所需访问权限。

result
Semaphore

此方法返回 true时,包含一个对象,该对象表示命名信号灯(如果调用成功,否则 null )。 此参数被视为未初始化。

返回

true 如果已成功打开命名信号量,则为 ;否则,为 false.

例外

name 是 null

name 是空字符串。

发生了 Win32 错误。

命名信号灯存在,但用户没有使用它所需的安全访问权限。

适用于