ReaderWriterLockSlim.IsUpgradeableReadLockHeld 属性

定义

获取一个值,该值指示当前线程是否已进入可升级模式的锁定状态。

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

注解

此属性适用于断言或其他调试目的。 不要使用它来控制程序执行流。

适用于