process.WaitForExit()异步process、WaitForExit

2023-09-03 01:22:54 作者:炙年

我要等待进程结束,但 process.WaitForExit()挂我的GUI。有没有一种基于事件的方式,或者我需要生成一个线程阻塞,直到退出,然后委托的情况下自己吗?

I want to wait for a process to finish, but process.WaitForExit() hangs my GUI. Is there an event-based way, or do I need to spawn a thread to block until exit, then delegate the event myself?

推荐答案

process.Exited + = [事件处理程序]

process.Exited += [EventHandler]