3

我正在使用 ReaderWriterLockSlim 来保护对 ASP.NET 应用程序上缓存的访问。MSDN 有使用锁的例子。然而这篇文章http://www.nobletech.co.uk/Articles/ReaderWriterLockMgr.aspx让我担心死锁。这真的有风险吗?MSDN 文档应该提到这一点吗?

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();
    }
}
4

1 回答 1

2

对不起,我错过了之前的阅读,

这个属性没有指定吗?

[HostProtectionAttribute(SecurityAction.LinkDemand, MayLeakOnAbort = true)]
于 2009-09-21T13:16:50.520 回答