Esiste comunque un reindirizzamento dell'output standard di un processo generato e acquisirlo mentre si verifica. Tutto ciò che ho visto fa un ReadToEnd al termine del processo. Mi piacerebbe essere in grado di ottenere l'output mentre viene stampato.C# ottiene l'output del processo mentre è in esecuzione
Edit:
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);
}
Sì, e inoltre è necessario impostare 'RedirectStandardOutput' su true affinché funzioni. – vcsjones
@vcsjones: basta scrivere post aggiuntivo. – Tigran
Come nella risposta [qui sopra] (http://stackoverflow.com/a/3642517/74757). –