Mutex.OpenExisting Method (String)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Opens the specified named mutex, if it already exists.

Namespace:   System.Threading
Assembly:  mscorlib (in mscorlib.dll)

static member OpenExisting : 
        name:string -> Mutex


Type: System.String

The name of the system mutex to open.

Return Value

Type: System.Threading.Mutex

An object that represents the named system mutex.

Exception Condition

name is an empty string.


name is longer than 260 characters.


name is null.


The named mutex does not exist.


A Win32 error occurred.


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

The OpenExisting method tries to open the specified named system mutex. If the system mutex does not exist, this method throws an exception instead of creating the system object. To create the system mutex when it does not already exist, use one of the Mutex constructors that has a name parameter.

Multiple calls to this method that use the same value for name do not necessarily return the same Mutex object, even though the objects that are returned represent the same named system mutex.

This method overload is equivalent to calling the OpenExisting(String, MutexRights) method overload and specifying MutexRights.Synchronize and MutexRights.Modify rights, combined by using the bitwise OR operation.

Specifying the MutexRights.Synchronize flag allows a thread to wait on the mutex, and specifying the MutexRights.Modify flag allows a thread to call the ReleaseMutex method.

This method does not request ownership of the mutex.

The following code example demonstrates the cross-process behavior of a named mutex with access control security. The example uses the OpenExisting(String) method overload to test for the existence of a named mutex.

If the mutex does not exist, it is created with initial ownership and access control security that denies the current user the right to use the mutex, but grants the right to read and change permissions on the mutex.

If you run the compiled example from two command windows, the second copy will throw an access violation exception on the call to OpenExisting(String). The exception is caught, and the example uses the OpenExisting(String, MutexRights) method overload to open the mutex with the rights needed to read and change the permissions.

After the permissions are changed, the mutex is opened with the rights required to enter and release it. If you run the compiled example from a third command window, it runs using the new permissions.

No code example is currently available or this language may not be supported.


Requires full trust for the immediate caller. This member cannot be used by partially trusted or transparent code.

Universal Windows Platform
Available since 8
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top