how to call Two processes sequentially

  • Thread starter Thread starter Ray5531
  • Start date Start date
R

Ray5531

In my application I have two lines like:

1) Process.Start(Exe1)
2)Process.Start(Exe2)

Problem is that these two guys run together ,and I want the first process is
run first and when it's finished the second process is called.

Just for your info .First process is CEAPPMANAGER.EXE which an executable
which installs a .Net compact framework on the device and the second process
is simply a console application

Thanks
 
Two solutions -
1) If you do not mind YOUR program blocking, you can do it like:

Process proc = Process.Start("prog1.exe");
proc.WaitForExit();

proc = Process.Start("prog2.exe");
proc.WaitForExit(); //you may not need this second one


2) If you want your program to be able to do other things while the first
process is running, you can add a handler for the Exited event:
Process proc = Process.Start("prog1.exe");
proc.Exited += new EventHandler(proc1_Exited);

and have a method for it:
private void proc1_Exited(object sender, EventArgs e)
{
Process proc = Process.Start("prog2.exe");
}


HTH
 
Excellent.I appreciate your help.

Ray
Adam Clauss said:
Two solutions -
1) If you do not mind YOUR program blocking, you can do it like:

Process proc = Process.Start("prog1.exe");
proc.WaitForExit();

proc = Process.Start("prog2.exe");
proc.WaitForExit(); //you may not need this second one


2) If you want your program to be able to do other things while the first
process is running, you can add a handler for the Exited event:
Process proc = Process.Start("prog1.exe");
proc.Exited += new EventHandler(proc1_Exited);

and have a method for it:
private void proc1_Exited(object sender, EventArgs e)
{
Process proc = Process.Start("prog2.exe");
}


HTH
 
Back
Top