Thread wurde abgebrochen Fehler bei der Verwendung von process.waitforexit ()

Ich habe unten Code, der von einer while-Schleife aufgerufen wird, damit er mehrmals hintereinander ausgeführt wird. Manchmal, aber nicht immer, bekomme ich einen Thread, der abgebrochen wurde. Fehler bei p.WaitforExit (). Hat jemand einen Einblick in das? soll ich nach p.WaitForExit p.Close () aufrufen?

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()

Antworten auf die Frage(1)

Ihre Antwort auf die Frage