문제

I want to start a program with C# (could use Process.Start()). Then my program should wait until the started program is closed, before it continues.
How do I do this?

도움이 되었습니까?

해결책

After you call Start() add: Process.WaitForExit()

 var myProcess = new Process {StartInfo = new ProcessStartInfo(processPath)};
 myProcess.Start().WaitForExit();

다른 팁

There are two mechanism. You can either hook the Process.Exited event or what you probably really want is to call Process.WaitForExit().

http://msdn.microsoft.com/en-us/library/system.diagnostics.process.exited.aspx

http://msdn.microsoft.com/en-us/library/system.diagnostics.process.waitforexit.aspx

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top