相关疑难解决方法(0)

释放互斥锁

我有一个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)

c# asp.net caching mutex

7
推荐指数
1
解决办法
8339
查看次数

如何检测正在运行的 MSI 安装

我正在寻找一种方法来检测 Windows Installer 安装是否已在进行中。到目前为止我发现的是:

  • 检查注册表项:
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\InProgress
  • 将 Windows Installer API 函数MSIInstallProduct与虚拟文件结合使用,该文件将返回特定的错误代码。

有人知道更聪明的解决方案吗?

c# windows-installer

5
推荐指数
1
解决办法
4079
查看次数

标签 统计

c# ×2

asp.net ×1

caching ×1

mutex ×1

windows-installer ×1