Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用process.waitforexit()时线程被中止错误_C#_Asp.net_Multithreading_Process - Fatal编程技术网

C# 使用process.waitforexit()时线程被中止错误

C# 使用process.waitforexit()时线程被中止错误,c#,asp.net,multithreading,process,C#,Asp.net,Multithreading,Process,下面的代码是从while循环调用的,因此它在一行中执行多次。有时,但并非总是,我在p.WaitforExit()上得到一个线程被中止的错误。有人对此有什么见解吗?我应该在p.WaitForExit之后调用p.Close()吗 string outputFileName = Path.Combine(Path.GetDirectoryName(recordingFileName), Guid.NewGuid() + ".mpg"); ProcessStartInfo startIn

下面的代码是从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.WaitOnential(SafeWaitHandle WaitHandle,UInt32毫秒激励,布尔HastThreadAffinity,布尔exitContext) 位于System.Threading.WaitHandle.WaitOne(Int64超时,布尔exitContext) 在System.Diagnostics.Process.WaitForExit时(Int32毫秒)
在System.Diagnostics.Process.WaitForExit()中,如果您是从ASP.NET页面调用它,则您看到的异常很可能是由于您在页面请求时遇到执行超时而导致的,并且该异常正在被中止。错误出现在p.WaitforExit()行上,因为ASP.NET页面在等待您开始返回的进程时,就在这一行。您可以在ASP.NET应用程序的web配置文件中更改默认执行超时(2.0中为110秒)

<httpRuntime  executionTimeout = "600" >

<httpRuntime  executionTimeout = "600" >
  HttpContext.Current.Server.ScriptTimeout