Click or drag to resize

InterprocessLockGetNamedMutex(String) Method

Gets a uniquely named inter-process Mutex associated with the specified name that identifies a source object needing concurrency locking.

Namespace: GSF.Threading
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.181-beta
Syntax
public static Mutex GetNamedMutex(
	string name
)
View Source

Parameters

name  String
Identifying name of source object needing concurrency locking (e.g., a path and file name).

Return Value

Mutex
A uniquely named inter-process Mutex specific to name; Mutex is created if it does not exist.
Exceptions
ExceptionCondition
ArgumentNullExceptionArgument name cannot be empty, null or white space.
UnauthorizedAccessExceptionThe named mutex exists, but the user does not have the minimum needed security access rights to use it.
Remarks

This function uses a hash of the name when creating the Mutex, not the actual name - this way restrictions on the name length do not need to be a user concern. All processes needing an inter-process Mutex need to use this same function to ensure access to the same Mutex.

The name can be a string of any length (must not be empty, null or white space) and is not case-sensitive. All hashes of the name used to create the global Mutex are first converted to lower case.

The Mutex created is "Global" meaning that it will be accessible to all active application sessions including terminal service sessions. This is accomplished internally by prefixing the Mutex name with "Global\"; it is not necessary for the user to be concerned with the length or contents of the name in this method as long as the same name is used for each application. Do not use this helper function if you need to create a specifically named or non-global Mutex, such as when you need to interact with another application using a Mutex that does not use this function.

See Also