I have code below that is getting called from a while loop so it's executing multiple times in a row. Sometimes, but not always, I end up getting a thread was being aborted error on the p.WaitforExit(). Does anyone have any insight into this? should I be calling p.Close() after p.WaitForExit?
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;
Thread was being aborted. mscorlib at System.Threading.WaitHandle.WaitOneNative(SafeWaitHandle waitHandle, UInt32 millisecondsTimeout, Boolean hasThreadAffinity, Boolean exitContext) at System.Threading.WaitHandle.WaitOne(Int64 timeout, Boolean exitContext) at System.Diagnostics.Process.WaitForExit(Int32 milliseconds) at System.Diagnostics.Process.WaitForExit()