加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – ProcessStartInfo.UseShellExecute = true并等待进程退出

发布时间:2020-12-15 21:10:37 所属栏目:百科 来源:网络整理
导读:我想使用 shell可执行文件来尊重启动应用程序的用户首选项,但我还需要知道该特定应用程序何时关闭. Process editProcess = new Process();ProcessStartInfo startInfo = new ProcessStartInfo();startInfo.FileName = filename;startInfo.Verb = "edit";star
我想使用 shell可执行文件来尊重启动应用程序的用户首选项,但我还需要知道该特定应用程序何时关闭.

Process editProcess = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = filename;
startInfo.Verb = "edit";
startInfo.UseShellExecute = true;
editProcess.StartInfo = startInfo;

// start the default editor
editProcess.Start();
editProcess.WaitForExit();

WaitForExit似乎在shell进程退出时返回,而不是在真正的进程退出时返回.

有没有更好的方法知道何时启动应用程序退出而不是手动解析注册表,找到正确的应用程序启动并显式启动该应用程序而不执行shell?

解决方法

处理流程退出事件:

editProcess.Exited += process_Exited;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读