ReaderWriterLockSlim.WaitingUpgradeCount 屬性

定義

取得等待進入可升級模式鎖定狀態的執行緒總數。Gets the total number of threads that are waiting to enter the lock in upgradeable mode.

public:
 property int WaitingUpgradeCount { int get(); };
public int WaitingUpgradeCount { get; }
member this.WaitingUpgradeCount : int
Public ReadOnly Property WaitingUpgradeCount As Integer

屬性值

等待進入可升級模式的執行緒總數。The total number of threads that are waiting to enter upgradeable mode.

範例

下列範例顯示如何使用WaitingUpgradeCount屬性來產生事件記錄檔專案, 如果封鎖的執行緒數目 (等待進入可升級模式) 超過閾值。The following example shows how to use the WaitingUpgradeCount property to generate an event log entry if the number of threads that are blocked, waiting to enter upgradeable mode, exceeds a threshold.

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

備註

此屬性僅適用于偵錯工具、分析和記錄用途, 而不是用來控制演算法的行為。Use this property only for debugging, profiling, and logging purposes, and not to control the behavior of an algorithm. 結果會在計算後立即變更。The results can change as soon as they have been calculated. 因此, 根據此屬性做出決策並不安全。Therefore, it is not safe to make decisions based on this property.

適用於