I'm using a ReaderWriterLockSlim to protect access to the cache on my ASP.NET application. MSDN has examples of using the lock. However this article http://www.nobletech.co.uk/Articles/ReaderWriterLockMgr.aspx has me worried about deadlocks. Is this really a risk? Should the MSDN documentation mention this?
public string Read(int key)
{
cacheLock.EnterReadLock();
// What if thread abort happens here before getting into the try block?!
try
{
return innerCache[key];
}
finally
{
cacheLock.ExitReadLock();
}
}