Asynchronous reading to console+StreamReader
Hi,
i am trying to send one command to console using Process.Start() method and want to read back the o/p line by line .
the code what i am using is as follows
p = new Process();
ProcessStartInfo psI = new ProcessStartInfo("cmd.exe");
psI.UseShellExecute = false;
psI.RedirectStandardInput = true;
psI.RedirectStandardOutput = true;
psI.RedirectStandardError = true;
psI.CreateNoWindow = true;
p.StartInfo = psI;
p.Start();
sw = p.StandardInput;
sr = p.StandardOutput;
err=p.StandardError;
sw.AutoFlush = true;
//executes the command
sw.WriteLine("nant -f:main.xml");
sw.Close();
richTBoxOutput.AppendText(sr.ReadToEnd());
mu code strucked here on the red line till the command completed
and display the entire o/p simultaneously
HOw can i dispaly the o/p line by line
|