1

ReaderWriterLockSlim が現在別のスレッドによって書き込みロックされているかどうかを知る方法は?

ReaderWriterLockSlim rwls = new ReaderWriterLockSlim()
var i = rwls.CurrentReadCount; 
// count of reading threads (but unfortunately there's no CurrentWriteCount property)
var j = rwls.IsWriteLockHeld; 
// check if current thread is holding the lock (limited to current thread)

/* none of above can do it */

はい、rwls.TryEnterWriteLock(1) を呼び出して、書き込みがロックされているかどうかを確認できますが、パフォーマンスが低下します

書き込みロック状態を取得する直接的な方法はありますか?

4

0 に答える 0