Oct 12
Most developers use the Process.Start static method to run an external application from within C# code. The Start method launches the external process asynchronously, meaning that your C# code continues executing and does not wait for the process to finish.
But occasionally you may wish to halt your program and wait for the external process to finish. So to launch a process synchronously from a C# application, the key is to create a Process object and call the WaitForExit method after you start the process. Be sure to finish with a call to the process Close method. Here is some sample code:
Process process = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo( "notepad.exe" ); process.StartInfo = startInfo; process.Start(); process.WaitForExit(); process.Close(); MessageBox.Show( "Process Complete" );