Gemstone Common Library
Show/Hide TOC

# NamedSemaphoreTryOpenExisting Method

Opens the specified named semaphore, if it already exists, and returns a value that indicates whether the operation succeeded.

## Definition

Namespace: Gemstone.Threading
Assembly: Gemstone.Common (in Gemstone.Common.dll) Version: 1.0.155 -- Release Build+a7d8ba87ff92af3282fc68a6fbfd37a854100b44
C#
View Source Request Example

    public static bool TryOpenExisting(
    	string name,
    	out NamedSemaphore?? semaphore
    )

VB
View Source Request Example

    Public Shared Function TryOpenExisting (
    	name As String,
    	<OutAttribute> ByRef semaphore As NamedSemaphore
    ) As Boolean

C++
View Source Request Example

    public:
    static bool TryOpenExisting(
    	String^ name,
    	[OutAttribute] NamedSemaphore^% semaphore
    )

JavaScript
View Source Request Example

    Gemstone.Threading.NamedSemaphore.TryOpenExisting = function(name, semaphore);

#### Parameters

name String
  The unique name identifying the semaphore. This name is case-sensitive. Use a backslash (\\) to specify a namespace, but avoid it elsewhere in the name. On Unix-based systems, the name should conform to valid file naming conventions, excluding slashes except for an optional namespace backslash. The name length is limited to 250 characters after any optional namespace.
semaphore NamedSemaphore
  When this method returns, contains a NamedSemaphore object that represents the named semaphore if the call succeeded, or null if the call failed. This parameter is treated as uninitialized.

#### Return Value

Boolean
true if the named semaphore was opened successfully; otherwise, false. In some cases, false may be returned for invalid names.

## Remarks

The name may be prefixed with Global\ or Local\ to specify a namespace. When the Global namespace is specified, the synchronization object may be shared with any processes on the system. When the Local namespace is specified, which is also the default when no namespace is specified, the synchronization object may be shared with processes in the same session. On Windows, a session is a login session, and services typically run in a different non-interactive session. On Unix-like operating systems, each shell has its own session. Session-local synchronization objects may be appropriate for synchronizing between processes with a parent/child relationship where they all run in the same session.

## See Also

#### Reference

NamedSemaphore Class
Gemstone.Threading Namespace