IsHeldByCurrentThread Property

Task Parallel System.Threading

Gets whether the lock is currently held by any thread.
Gets whether the lock is held by the current thread.

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

Syntax

Visual Basic (Declaration)
Public ReadOnly Property IsHeldByCurrentThread As Boolean
C#
public bool IsHeldByCurrentThread { get; }

Remarks

If the lock was initialized to track owner threads, this will return whether the lock is acquired by the current thread. It is invalid to use this property when the lock was initialized to not track thread ownership.

Exceptions

ExceptionCondition
System..::.InvalidOperationException Thread ownership tracking is disabled.

See Also