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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With