ReaderWriterLockSlim.IsWriteLockHeld Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a value that indicates whether the current thread has entered the lock in write mode.
public:
property bool IsWriteLockHeld { bool get(); };
public bool IsWriteLockHeld { get; }
member this.IsWriteLockHeld : bool
Public ReadOnly Property IsWriteLockHeld As Boolean
Property Value
true
if the current thread has entered write mode; otherwise, false
.
Examples
The following example shows how to use the IsWriteLockHeld property to generate an assert if the current thread has entered write mode unexpectedly.
using (ReaderWriterLockSlim rwLock = new ReaderWriterLockSlim()) {
Using rwLock As New ReaderWriterLockSlim()
Debug.Assert(!rwLock.IsWriteLockHeld,
String.Format("Thread {0} is still holding the write lock after MyFunction has finished.",
Thread.CurrentThread.ManagedThreadId));
Debug.Assert(Not rwLock.IsWriteLockHeld, _
String.Format("Thread {0} is still holding the write lock after MyFunction has finished.", _
Thread.CurrentThread.ManagedThreadId))
Remarks
This property is intended for use in asserts or for other debugging purposes. Do not use it to control the flow of program execution.
Applies to
Feedback
https://aka.ms/ContentUserFeedback.
Kommer snart: I hele 2024 udfaser vi GitHub-problemer som feedbackmekanisme for indhold og erstatter det med et nyt feedbacksystem. Du kan få flere oplysninger under:Indsend og få vist feedback om