如何知道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)来检查它是否被写入锁定但这会降低性能
有没有直接获得写锁定状态的方法?