Export (0) Print
Expand All

Monitor.IsEntered Method

.NET Framework 4.6 and 4.5

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

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

public static bool IsEntered(
	Object obj
)

Parameters

obj
Type: System.Object

The object to test.

Return Value

Type: System.Boolean
true if the current thread holds the lock on obj; otherwise, false.

ExceptionCondition
ArgumentNullException

obj is null.

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

Use this method with diagnostic tools, such as the Assert method and the Contract class, to debug locking issues that involve the Monitor class.

.NET Framework

Supported in: 4.6, 4.5

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft