Question

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();
    }
}
Was it helpful?

Solution

Sorry, i miss read earlier,

Does this attribute not specify that?

[HostProtectionAttribute(SecurityAction.LinkDemand, MayLeakOnAbort = true)]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top