ReaderWriterLockSlim.WaitingUpgradeCount 屬性

定義

取得等待進入可升級模式鎖定狀態的執行緒總數。

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

備註

僅針對偵錯、分析及記錄目的使用這個屬性,而不是控制演算法的行為。 結果可以在計算結果後立即變更。 因此,根據這個屬性做出決策並不安全。

適用於