Process Hanging

G

Guest

Hello ,

I am developping a program for Win98 plateform, and I am stucking with a
problem, hope you can help me.

I have a program running 2 process :
- One process running the Xcopy.exe
- When the first process is finished, it runs another Exe process (HHC.exe)

The code is below:

// Xcopy.exe process to copy directory 1 to 2
compiler.StartInfo.FileName = "Xcopy.exe";
compiler.StartInfo.Arguments = Dir1 + Dir2 + " " + "/S /Y";
compiler.StartInfo.UseShellExecute = false;
compiler.StartInfo.CreateNoWindow = true;
compiler.Start();

while (!compiler.HasExited)
{
Application.DoEvents();
{

// Process 2: Recompilation the new CHM with Hhc.exe external command
compiler.StartInfo.FileName = Dir 2 + "\\" + "hhc.exe";
compiler.StartInfo.Arguments = Dir2 + "\\" + "Help.hhp";
compiler.StartInfo.UseShellExecute = false;
compiler.StartInfo.CreateNoWindow = true;
compiler.Start();

while (!compiler.HasExited)
{
Application.DoEvents();
}
 
J

Jon Skeet [C# MVP]

Samantha said:
I am developping a program for Win98 plateform, and I am stucking with a
problem, hope you can help me.

I have a program running 2 process :
- One process running the Xcopy.exe
- When the first process is finished, it runs another Exe process (HHC.exe)

The code is below:

while (!compiler.HasExited)
{
Application.DoEvents();
}

That's a very expensive way of waiting for the process to finish - it's
basically tight-looping. It would be better to spin off a new thread
(or threadpool task) to wait for the process to finish, and then call
Invoke on your form to let the UI thread know that the process has
finished.
 

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