我有一个Web应用程序需要利用应用程序缓存来存储数据(由于在请求的基础上获取该数据的高开销).请参阅上一篇文章:/sf/answers/1187337371/
这种方法似乎运行良好,但我在网站的错误中看到以下偶然的错误:
System.ApplicationException: Object synchronization method was called from an
unsynchronized block of code.
at System.Threading.Mutex.ReleaseMutex()
at InboxInsight.Web.Web_Controls.Twitter.TwitterFeed.GetTwitterData(HttpContext context)
at InboxInsight.Web.Web_Controls.Twitter.TwitterFeed.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Run Code Online (Sandbox Code Playgroud)
作为参考,这是代码块:
public string GetData(HttpContext context)
{
var cache = context.Cache;
Mutex mutex = null;
string data = (string)cache[CacheKey];
// Start check to see if available on cache
if (data == null)
{
try
{
// Lock base on resource key
// (note that not all chars are valid for name) …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种方法来检测 Windows Installer 安装是否已在进行中。到目前为止我发现的是:
有人知道更聪明的解决方案吗?