Click or drag to resize

InterprocessLockGetNamedMutex(Boolean) Method

Gets a uniquely named inter-process Mutex associated with the running application, typically used to detect whether an instance of the application is already running.

Namespace: GSF.Threading
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.181-beta
Syntax
public static Mutex GetNamedMutex(
	bool perUser = true
)
View Source

Parameters

perUser  Boolean  (Optional)
Indicates whether to generate a different name for the Mutex dependent upon the user running the application.

Return Value

Mutex
A uniquely named inter-process Mutex specific to the application; Mutex is created if it does not exist.
Exceptions
ExceptionCondition
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 assembly's GUID when creating the Mutex, if it is available. If it is not available, it uses a hash of the simple name of the assembly. Although the name is hashed to help guarantee uniqueness, it is still entirely possible that another application may use that name with the same hashing algorithm to generate its Mutex name. Therefore, it is best to ensure that the GuidAttribute is defined in the AssemblyInfo of your application.

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\". 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