ReaderWriterLockSlim.IsReadLockHeld 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 read mode.
public:
property bool IsReadLockHeld { bool get(); };
public bool IsReadLockHeld { get; }
member this.IsReadLockHeld : bool
Public ReadOnly Property IsReadLockHeld As Boolean
Property Value
true
if the current thread has entered read mode; otherwise, false
.
Examples
The following example shows how to use the IsReadLockHeld property to generate an assert if the current thread has entered read mode unexpectedly.
using (ReaderWriterLockSlim rwLock = new ReaderWriterLockSlim()) {
Using rwLock As New ReaderWriterLockSlim()
Debug.Assert(!rwLock.IsReadLockHeld,
String.Format("Thread {0} already held the read lock when MyFunction began executing.",
Thread.CurrentThread.ManagedThreadId));
Debug.Assert(Not rwLock.IsReadLockHeld, _
String.Format("Thread {0} already held the read lock when MyFunction began executing.", _
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
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET