I have a frustration with ReaderWriterLockSlim and delaying ExitWriteLock. Why is the WriteLock released in timers callback?
var _lock = new ReaderWriterLockSlim();
_lock.EnterWriteLock();
Assert.AreEqual(true, _lock.IsWriteLockHeld); // good
System.Threading.Timer timer = new Timer(state =>
{
_lock.ExitWriteLock(); //throws exception that lock is not held
}, null, 1, -1);
Thread.Sleep(1000);
Assert.AreEqual(false, _lock.IsWriteLockHeld);