In the latest revision of the framework, ReaderWriterLockSlim is totally fair and thus a call to TryEnterReadLock musn't succeed when writers are waiting to get the lock before them (and when the lock is currently in read mode).
ev2.WaitOne ();
Assert.IsFalse (v.TryEnterWriteLock (100));
ev2.WaitOne ();
Assert.IsFalse (v.TryEnterWriteLock (100));
- Assert.IsTrue (v.TryEnterReadLock (100));
+ Assert.IsFalse (v.TryEnterReadLock (100));
Assert.IsTrue (v.TryEnterWriteLock (100));
}
Assert.IsTrue (v.TryEnterWriteLock (100));
}