Process hangs with RedirectStandardOutput
-
:( Hi I am trying to compile a workspace using Msdev.exe (Visual Studio 6) . I am using the command line and want to redirect the output into a rich textbox on my form. When an error in compilation occur the process is hanged until i stop my application and only then the Msdev is showing the error.
System.IntPtr PrHndle; Process Prc = new Process(); Prc.StartInfo.FileName = VS6EXEPath; Prc.StartInfo.Arguments = WorkSpace + CompileCommandString; Prc.StartInfo.UseShellExecute = false; Prc.StartInfo.RedirectStandardOutput=true; Prc.Start(); PrHndle = Prc.Handle; StreamReader SR = Prc.StandardOutput; while (SR.EndOfStream != true) { rtbCmdOutput.Text = rtbCmdOutput.Text + "\r\n" + SR.ReadLine(); } Prc.WaitForExit();
Same code works good with appliaction. Please help:(Have a nice Day
-
:( Hi I am trying to compile a workspace using Msdev.exe (Visual Studio 6) . I am using the command line and want to redirect the output into a rich textbox on my form. When an error in compilation occur the process is hanged until i stop my application and only then the Msdev is showing the error.
System.IntPtr PrHndle; Process Prc = new Process(); Prc.StartInfo.FileName = VS6EXEPath; Prc.StartInfo.Arguments = WorkSpace + CompileCommandString; Prc.StartInfo.UseShellExecute = false; Prc.StartInfo.RedirectStandardOutput=true; Prc.Start(); PrHndle = Prc.Handle; StreamReader SR = Prc.StandardOutput; while (SR.EndOfStream != true) { rtbCmdOutput.Text = rtbCmdOutput.Text + "\r\n" + SR.ReadLine(); } Prc.WaitForExit();
Same code works good with appliaction. Please help:(Have a nice Day
Instead of blocking the thread waiting for output, use an event to listen for output:
Process proc = ...;
proc.OutputDataReceived += OutputDataReceivedHandler;...
void OutputDataReceivedHandler(object sender, System.Diagnostics.DataReceivedEventArgs e)
{
rtbCmdOutput.AppendText(e.Data);
}Tech, life, family, faith: Give me a visit. I'm currently blogging about: Sound The Great Shofar! The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
-
Instead of blocking the thread waiting for output, use an event to listen for output:
Process proc = ...;
proc.OutputDataReceived += OutputDataReceivedHandler;...
void OutputDataReceivedHandler(object sender, System.Diagnostics.DataReceivedEventArgs e)
{
rtbCmdOutput.AppendText(e.Data);
}Tech, life, family, faith: Give me a visit. I'm currently blogging about: Sound The Great Shofar! The apostle Paul, modernly speaking: Epistles of Paul Judah Himango