views:

334

answers:

1

Hi Gang, I have written C# command window application. I'm running bunch of processes on command line inside the main(). For e.g.

void main()
{
    process p1 = new process()
    set p1 properties
    p1.start()
 -->p1.StandardInput.WriteLine("start /WAIT cmd.exe /c BUILD -cZP");
}

This line will execute some program in a new command window. While executing that last line I will break this execution using ctrl+c and return the control to execution of the main program.

loop through to output to the execution window.

p1.StandardInput.WriteLine("Done some action"); 
p1.WaitForExit();
p1.Close();

The above three lines are not executed. The question is p1 never closes to execute following lines which I have in my program.

process p2 = new process()
...
p2.waitforExit()
p2.close.

Any insight for above challenges will be great. thx.

+1  A: 

If I understand you correctly (which I admit I may not be understanding you), I believe the problem is that when you press CTRL-C to break into process p1, you are actually killing that process. Then you are trying to send text to the standard input for the process, which has just been killed. Since the process is no longer available to take your input, the main program hangs. That's my best guess.

Jeffrey L Whitledge