Process.Start Problem with WaitForExit(), WaitForExit DOES NOT WA

G

Guest

I have the code below, the first process takes about 10 minutes to finish.
But the waitForExit doesn't seem to wait when I debug the program, it go
immediately to execute code after the WaitForExit(). The first process
basically launch a DOS batch file to do some task, am I missing anything?

executable = "setup_listener.bat";
process1 = new Process();
process1.StartInfo.UseShellExecute = false;
process1.StartInfo.CreateNoWindow = false;
process1.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process1.StartInfo.FileName = executable;
//process1.StartInfo.RedirectStandardOutput = true;
process1.Start();
process1.WaitForExit();

executable = "create_xdb_service.bat";
process3 = new Process();
process3.StartInfo.UseShellExecute = false;
process3.StartInfo.CreateNoWindow = false;
process3.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process3.StartInfo.FileName = executable;
//process3.StartInfo.RedirectStandardOutput = true;
process3.Start();
process3.WaitForExit();
 
R

Richard A. Lowe

Well, what are you batch files doing? It's possible, I guess, that they are
starting other processes in a way that they do not block the .bat file
process.
 
G

Guest

It is calling the setup.exe of a third party application, which launches a
java program to do some installation tasks, file copies, write registry,
create windows services, etc.
 
R

Richard A. Lowe

I'm going to bet that's why - can you maybe start the installer from your
process? Worth seeing if it will block when you start it directly
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top