ReaderWriterLockSlim.WaitingUpgradeCount 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取等待进入可升级模式锁定状态的线程总数。
public:
property int WaitingUpgradeCount { int get(); };
public int WaitingUpgradeCount { get; }
member this.WaitingUpgradeCount : int
Public ReadOnly Property WaitingUpgradeCount As Integer
属性值
等待进入可升级模式的线程总数。
示例
以下示例演示如何使用 WaitingUpgradeCount 属性生成事件日志条目(如果阻止的线程数(等待进入可升级模式)超过阈值。
using (ReaderWriterLockSlim rwLock = new ReaderWriterLockSlim()) {
Using rwLock As New ReaderWriterLockSlim()
int waitingUpgradeableReadCt = rwLock.WaitingUpgradeCount;
if (waitingUpgradeableReadCt > UPGRADEABLEREAD_THRESHOLD)
{
performanceLog.WriteEntry(String.Format(
"{0} blocked upgradeable reader threads; exceeds recommended maximum.",
waitingUpgradeableReadCt));
}
Dim waitingUpgradeableReadCt As Integer = rwLock.WaitingUpgradeCount
If waitingUpgradeableReadCt > UPGRADEABLEREAD_THRESHOLD Then
performanceLog.WriteEntry(String.Format( _
"{0} blocked upgradeable reader threads; exceeds recommended maximum.", _
waitingUpgradeableReadCt))
End If
注解
仅对调试、分析和日志记录目的使用此属性,而不是控制算法的行为。 一旦计算结果,结果就会发生更改。 因此,基于此属性做出决策是不安全的。