Mono Class Library: System.Threading.Monitor Overview | Members

System.Threading.Monitor.Exit Method

Releases an exclusive lock on the specified object . [Edit]

[System.Runtime.ConstrainedExecution.ReliabilityContract(System.Runtime.ConstrainedExecution.Consistency.WillNotCorruptState, System.Runtime.ConstrainedExecution.Cer.Success)]
public static void Exit (object obj)

Parameters

obj
The object on which to release the lock. [Edit]

Exceptions

TypeReason
ArgumentNullExceptionobj is null. [Edit]
System.Threading.SynchronizationLockExceptionThe current thread does not own the lock for the specified object. [Edit]

Remarks

This method releases an exclusive lock on obj. The caller is required to own the lock on obj .

If the caller owns the lock on the specified object, and has made an equal number of Monitor.Exit(object) and Monitor.Enter(object) calls for the object, then the lock is released. If the caller has not invoked Monitor.Exit(object) as many times as Monitor.Enter(object) , the lock is not released.

Note: If the lock is released and there are other threads in the ready queue for the object, one of the threads will acquire the lock. If there are other threads in the waiting queue waiting to acquire the lock, they are not automatically moved to the ready queue when the owner of the lock calls Monitor.Exit(object). To move one or more waiting threads into the ready queue, call Monitor.Pulse(object) or Monitor.PulseAll(object) prior to invoking Monitor.Exit(object).

[Edit]

Requirements

Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0