ReleaseMutex Method
Collapse the table of content
Expand the table of content

Mutex.ReleaseMutex Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Releases the Mutex once.

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

public void ReleaseMutex()


The calling thread does not own the mutex.

A thread that owns a mutex can specify the same mutex in repeated wait function calls without blocking its execution. The number of calls is kept by the common language runtime. The thread must call ReleaseMutex the same number of times to release ownership of the mutex.

If a thread terminates while owning a mutex, the mutex is said to be abandoned. The state of the mutex is set to signaled and the next waiting thread gets ownership. In .NET for the desktop, if no one owns the mutex, the state of the mutex is signaled and an AbandonedMutexException is thrown in the next thread that acquires the mutex. This behavior is different for different versions of Windows Phone.

Windows Phone 8 Windows Phone 8: In Windows Phone 8, an Exception is thrown in the next thread.

Windows Phone OS 7.1 Windows Phone OS 7.1: In Windows Phone OS 7.1, no exception is thrown.

Caution noteCaution:

An abandoned mutex often indicates a serious error in the code. When a thread exits without releasing the mutex, the data structures protected by the mutex might not be in a consistent state. The next thread to request ownership of the mutex can handle this exception and proceed, if the integrity of the data structures can be verified.

In the case of a system-wide mutex, an abandoned mutex might indicate that an application has been terminated abruptly (for example, by using Windows Task Manager).

Windows Phone OS

Supported in: 8.1, 8.0, 7.1

Windows Phone

© 2017 Microsoft