Does the MSDN ReaderWriterLockSlim example use the risk of deadlock?

I am using ReaderWriterLockSlim to protect cache access in my ASP.NET application. There are examples of using locks on MSDN. However, this article http://www.nobletech.co.uk/Articles/ReaderWriterLockMgr.aspx makes me worry about deadlocks. Is this really a risk? Should be mentioned in the MSDN documentation?

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();
    }
}
+3
source share
1 answer

Sorry, I missed the reading earlier,

Is this attribute not specified?

[HostProtectionAttribute(SecurityAction.LinkDemand, MayLeakOnAbort = true)]
+2
source

Source: https://habr.com/ru/post/1718189/


All Articles