共用方式為


ReaderWriterLockSlim.IsReadLockHeld 屬性

定義

取得值,表示目前執行緒是否已進入讀取模式的鎖定。

public:
 property bool IsReadLockHeld { bool get(); };
public bool IsReadLockHeld { get; }
member this.IsReadLockHeld : bool
Public ReadOnly Property IsReadLockHeld As Boolean

屬性值

Boolean

如果目前執行緒已進入讀取模式,則為 true;否則為 false

範例

下列範例示範如何使用 IsReadLockHeld 屬性,在目前的執行緒意外進入讀取模式時產生判斷提示。

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))

備註

此屬性適用于判斷提示或其他偵錯用途。 請勿使用它來控制程式執行的流程。

適用於