467,136 Members | 1,366 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,136 developers. It's quick & easy.

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

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();
Nov 16 '05 #1
  • viewed: 22089
Share:
3 Replies
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.

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"James Li" <Ja*****@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...
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();

Nov 16 '05 #2
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.

"Richard A. Lowe" wrote:
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.

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"James Li" <Ja*****@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...
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();


Nov 16 '05 #3
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
--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"James Li" <Ja*****@discussions.microsoft.com> wrote in message
news:09**********************************@microsof t.com...
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.

"Richard A. Lowe" wrote:
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.

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"James Li" <Ja*****@discussions.microsoft.com> wrote in message
news:BC**********************************@microsof t.com...
>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();


Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Piedro | last post: by
reply views Thread by henning.friese@gmx.de | last post: by
11 posts views Thread by Kirk | last post: by
10 posts views Thread by Stephany Young | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.