C # obtener salida del proceso mientras se ejecuta
¿Existe de todos modos para redirigir la salida estándar de un proceso generado y capturarlo como si estuviera sucediendo? Todo lo que he visto simplemente hace un ReadToEnd después de que el proceso haya finalizado. Me gustaría poder obtener la salida cuando se está imprimiendo.
Editar:
private void ConvertToMPEG()
{
// Start the child process.
Process p = new Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
//Setup filename and arguments
p.StartInfo.Arguments = String.Format("-y -i \"{0}\" -target ntsc-dvd -sameq -s 720x480 \"{1}\"", tempDir + "out.avi", tempDir + "out.mpg");
p.StartInfo.FileName = "ffmpeg.exe";
//Handle data received
p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
p.Start();
}
void p_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
Debug.WriteLine(e.Data);
}