ReaderWriterLockSlim.IsUpgradeableReadLockHeld 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得值,表示目前執行緒是否已進入可升級模式的鎖定。
public:
property bool IsUpgradeableReadLockHeld { bool get(); };
public bool IsUpgradeableReadLockHeld { get; }
member this.IsUpgradeableReadLockHeld : bool
Public ReadOnly Property IsUpgradeableReadLockHeld As Boolean
屬性值
如果目前執行緒已進入可升級模式,則為 true
,否則為 false
。
範例
下列範例示範如何使用 IsUpgradeableReadLockHeld 屬性,在目前的執行緒意外進入可升級模式時產生判斷提示。
using (ReaderWriterLockSlim rwLock = new ReaderWriterLockSlim()) {
Using rwLock As New ReaderWriterLockSlim()
Debug.Assert(!rwLock.IsUpgradeableReadLockHeld,
String.Format("Thread {0} has entered the upgradeable read lock while MyFunction is still executing.",
Thread.CurrentThread.ManagedThreadId));
Debug.Assert(Not rwLock.IsUpgradeableReadLockHeld, _
String.Format("Thread {0} has entered the upgradeable read lock while MyFunction is still executing.", _
Thread.CurrentThread.ManagedThreadId))
備註
這個屬性適用于判斷提示或其他偵錯用途。 請勿使用它來控制程式執行的流程。