명령 줄 앱을 사용하여 비디오를 인코딩합니다.명령 줄에서 응답을 다시 구문 분석합니다.
퍼센트 완료 : 미디어 인코딩으로이 업데이트됩니다
34 %이 앱라는 한 줄을 반환합니다. 프로세스 클래스를 사용하여 표준 출력을 계속 확인하고 기본 실행 스크립트로 다시 전달하는 방법이 있습니까? 프로세스를 시작한 클래스가 있고 표준 출력을 stringbuilder에 씁니다.하지만 계속 검사하는 방법을 알고 싶습니다. 이
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;
}
새 데이터가 도착할 때 "CalledBack"이 될 StartInfo의 일부로 대리인을 전달할 수 있습니다. – Jodrell