我将执行一个进程(lame.exe)将WAV文件编码为MP3.
我想处理进程的STDOUT和STDERR以显示进度信息.
我需要使用线程吗?我无法理解它.
一些简单的示例代码将不胜感激.
谢谢
我不会提供所有代码,而是我想要做的一个例子.我有这个代码用于从外部进程stderr更新GUI元素.
我设置了这样的流程:
ProcessStartInfo info = new ProcessStartInfo(command, arguments);
// Redirect the standard output of the process.
info.RedirectStandardOutput = true;
info.RedirectStandardError = true;
info.CreateNoWindow = true;
// Set UseShellExecute to false for redirection
info.UseShellExecute = false;
proc = new Process();
proc.StartInfo = info;
proc.EnableRaisingEvents = true;
// Set our event handler to asynchronously read the sort output.
proc.OutputDataReceived += new DataReceivedEventHandler(proc_OutputDataReceived);
proc.ErrorDataReceived += new DataReceivedEventHandler(proc_ErrorDataReceived);
proc.Exited += new EventHandler(proc_Exited);
proc.Start();
// Start the asynchronous read of the sort output stream. Note …Run Code Online (Sandbox Code Playgroud)