ReaderWriterLockSlim.WaitingWriteCount 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取等待进入写入模式锁定状态的线程总数。
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
注解
此属性仅用于调试、分析和日志记录目的,而不用于控制算法的行为。 计算结果后,结果可能会立即更改。 因此,基于此属性做出决策是不安全的。