System.Threading.Monitor.IsEntered Method

Determines whether the current thread holds the lock on the specified object.

Syntax

public static bool IsEntered (object obj)

Parameters

obj
The object to test.

Returns

true if the current thread holds the lock on obj; otherwise, false.

Remarks

This method works only for locks that are acquired by using the methods of the System.Threading.Monitor class, or by using the C# lock statement or the Visual Basic SyncLock statement, which are implemented with System.Threading.Monitor.

Use this method with diagnostic tools, such as the System.Diagnostics.Debug.Assert(bool) method and the System.Diagnostics.Contracts.Contract class, to debug locking issues that involve the System.Threading.Monitor class.

Requirements

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