共用方式為


ReaderWriterLockSlim.WaitingWriteCount 屬性

定義

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

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

屬性值

等待進入寫入模式的執行緒總數。

範例

下列範例示範如何使用 WaitingWriteCount 屬性來產生事件記錄檔專案,如果封鎖的執行緒數目,等候進入寫入模式,就會超過臨界值。

using (ReaderWriterLockSlim rwLock = new ReaderWriterLockSlim()) {
Using rwLock As New ReaderWriterLockSlim()
int waitingWriteCt = rwLock.WaitingWriteCount;
if (waitingWriteCt > WRITE_THRESHOLD)
{
    performanceLog.WriteEntry(String.Format(
        "{0} blocked writer threads; exceeds recommended maximum.", 
        waitingWriteCt));
}
Dim waitingWriteCt As Integer = rwLock.WaitingWriteCount
If waitingWriteCt > WRITE_THRESHOLD Then
    performanceLog.WriteEntry(String.Format( _
        "{0} blocked writer threads; exceeds recommended maximum.", _
        waitingWriteCt))
End If

備註

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

適用於