Share via


Monitor.Exit Method

Releases an exclusive lock on a specified object.

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

Syntax

[MethodImplAttribute]
public static void Exit (
         Objectobj
)

Parameters

  • obj
    The object whose lock you want to release.

Remarks

Use the Enter method to acquire the specified Monitor object or the object passed as the parameter. If another thread has executed the Enter method on the same object but has not yet executed the corresponding Exit method, the current thread will be blocked until the other thread releases the object. It is legal for the same thread to invoke Enter more than once without it blocking. Note, however, that an equal number of Exit calls must be invoked before other threads waiting on the object will be unblocked.

Use the Monitor class to lock objects (reference types), not value types.

Version Information

Available in .NET Micro Framework version 2.0, 2.5

See Also

Reference

Monitor Class
Monitor Members
System.Threading Namespace