使用命令行应用编码视频。该应用程序返回线,说:从命令行重新解析响应
%完成:34%
的媒体编码此更新。有没有办法使用流程类继续检查标准输出并将其传递回主执行脚本?我有一个启动过程的类,然后将标准输出写入到stringbuilder,但我想知道如何继续检查它。这是CURENT代码...
public static Dictionary<string, string> StartProcess(string exePathArg, string argumentsArg, int timeToWaitForProcessToExit)
{
//the dictionary with the
Dictionary<string, string> retDirects = new Dictionary<string, string>();
using (Process p = new Process())
{
p.StartInfo.FileName = exePathArg;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.Arguments = argumentsArg;
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
try
{
p.Start();
p.WaitForExit(timeToWaitForProcessToExit);
int exitCode;
try
{
exitCode = p.ExitCode;
StreamReader standardOutput = p.StandardOutput;
StreamReader standardError = p.StandardError;
retDirects.Add("StandardOutput", standardOutput.ReadToEnd());
retDirects.Add("StandardError", standardError.ReadToEnd());
}
catch { }
}
catch { }
finally
{
try
{
p.Kill();
p.CloseMainWindow();
}
catch { }
}
}
return retDirects;
}
我记得你可以传入一个委托,作为StartInfo的一部分,当新数据到达时将被“CalledBack”调用。 – Jodrell