【发布时间】:2010-11-30 01:55:03
【问题描述】:
我正在使用 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();
}
}
【问题讨论】:
标签: asp.net thread-safety deadlock readerwriterlockslim