等到一个进程结束 [英] Wait until a process ends

查看:24
本文介绍了等到一个进程结束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序

Process.Start()

启动另一个应用程序ABC".我想等到该应用程序结束(进程终止)并继续执行.我该怎么做?

to start another application 'ABC'. I want to wait till that application ends (process dies) and continue my execution. How can I do it?

可能有多个应用程序 'ABC' 实例同时运行.

There may be multiple instances of the application 'ABC' running at the same time.

推荐答案

我想你只是想要这个:

var process = Process.Start(...);
process.WaitForExit();

有关方法,请参阅 MSDN 页面.它还有一个重载,您可以在其中指定超时,因此您不会永远等待.

See the MSDN page for the method. It also has an overload where you can specify the timeout, so you're not potentially waiting forever.

这篇关于等到一个进程结束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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