检查Windows Installer互斥锁的可用性 [英] check for windows installer mutex availability

查看:62
本文介绍了检查Windows Installer互斥锁的可用性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一项集成测试中,我有两个线程卸载并安装程序,但是按顺序运行时它们会产生错误无法获取执行互斥体。系统错误258。

In one of my integration tests, I have two threads that uninstall then install a program but when run in sequence they generate an error Failed to grab execution mutex. System error 258.

要解决这个问题,卸载后我必须睡觉。我尝试检查msiexec进程是否正在运行,但始终存在2-3个,因此这不是一个很好的指标。有没有办法检查msiexec执行互斥体是否可用?

To get around this I have to sleep after the uninstall. I tried checking if the msiexec process was running but there were consistently 2-3 so it's not a good indicator. Is there a way to check if the msiexec execution mutex is available?

推荐答案

    bool msiIsRunning = false;
    try
    {
        using(var mutex = Mutex.OpenExisting(@"Global\_MSIExecute"))
        {
            msiIsRunning = true;
        }
    }
    catch (Exception)
    {
       // Mutex not found; MSI isn't running
    }

这篇关于检查Windows Installer互斥锁的可用性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆