【发布时间】:2010-01-08 14:37:51
【问题描述】:
我下面的代码是从 while 循环中调用的,因此它连续执行多次。有时,但并非总是如此,我最终会在 p.WaitforExit() 上得到一个线程被中止的错误。有没有人对此有任何见解?我应该在 p.WaitForExit 之后调用 p.Close() 吗?
string outputFileName = Path.Combine(Path.GetDirectoryName(recordingFileName), Guid.NewGuid() + ".mpg");
ProcessStartInfo startInfo = new ProcessStartInfo(ffmpegfileName);
startInfo.Arguments = "-i \"" + recordingFileName + "\" -r 30 -sameq \"" + outputFileName + "\"";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process p = Process.Start(startInfo);
p.WaitForExit();
if (p.ExitCode != 0)
{
throw new Exception("exited with an exit code of " + p.ExitCode.ToString(CultureInfo.InvariantCulture) + ".");
}
return outputFileName;
线程被中止。 mscorlib 在 System.Threading.WaitHandle.WaitOneNative(SafeWaitHandle waitHandle,UInt32 毫秒超时,布尔 hasThreadAffinity,布尔 exitContext) 在 System.Threading.WaitHandle.WaitOne(Int64 超时,布尔型 exitContext) 在 System.Diagnostics.Process.WaitForExit(Int32 毫秒) 在 System.Diagnostics.Process.WaitForExit()
【问题讨论】:
标签: c# asp.net multithreading process