July 28, 2014
Determines whether the current thread holds a lock on the specified object.
Assembly: mscorlib (in mscorlib.dll)
The method applies to locks that are taken by using the methods of the Monitor class (that is, the Enter, TryEnter, and Wait methods), and to locks that are taken by using the C# lock statement and the Visual Basic SyncLock statement, because the implementations of those statements use the Monitor class.
Use the method with asserts and code contracts to diagnose problems with locks. For example, the following code shows a method that begins by asserting that the current thread has taken a lock on a global object.