.NET Framework Class Library |
SpinLock..::.IsHeldByCurrentThread Property |
SpinLock Structure See Also Send Feedback |
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
Exception | Condition |
---|---|
System..::.InvalidOperationException | Thread ownership tracking is disabled. |