bslim

Hi all,

I had to execute 2 processes.

process1 = System.Diagnostics.Process.Start("CMD.exe", strCmdLine);

How can I ensure that process1 had finished before I run process2

Please help.

Thanks



Re: Visual C# General How to ensure the first process had finished

Bulldog.NET

Hi

Here is a sample code to run the second process after the first one has finished running:-

Code Snippet

public void RunProcesses()

{

string proc1 = @"C:/Proc1.exe";

Process run_proc1 = new Process();

run_proc1.StartInfo.FileName = (proc1);

run_proc1.StartInfo.WindowStyle = ProcessWindowStyle.Normal;

run_proc1.Start();

run_proc1.WaitForExit();

string proc2 = @"C:/Proc2.exe";

Process run_proc2 = new Process();

run_proc2.StartInfo.FileName = (proc2);

run_proc2.StartInfo.WindowStyle = ProcessWindowStyle.Normal;

run_proc2.Start();

run_proc2.WaitForExit();

}

Hope this helps:-






Re: Visual C# General How to ensure the first process had finished

bslim

Hi,

Thanks for your info.





Re: Visual C# General How to ensure the first process had finished

Bulldog.NET

Hi bslim

Did the program work if so please Mark as Answer.

Happy coding