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

C# ProcessStartInfo.UseShellExecute=true并等待进程退出,c#,.net,shellexecute,C#,.net,Shellexecute,我想使用shell可执行文件以尊重用户对要启动的应用程序的偏好,但我还需要知道特定应用程序何时关闭 Process editProcess = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = filename; startInfo.Verb = "edit"; startInfo.UseShellExecute = true; editProcess.StartInf

我想使用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;

我也试过了,但它的行为方式和我不希望的一样,也就是在shell进程中激发?退出并且启动的应用程序仍在运行..我遇到了类似的问题。你解决了这个问题吗?你解决了吗?