本文介绍了进程访问超时时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我有这个方法来执行命令

 private static int ExecuteCommand(string command,int timeout)
{
var processInfo = new ProcessStartInfo(cmd.exe,/ C+ command)
{
CreateNoWindow = true,
UseShellExecute = false,
WorkingDirectory = C:\\,
};

var process = Process.Start(processInfo);
process.WaitForExit(timeout);
var exitCode = process.ExitCode;
process.Close();

返回exitCode;
}





有时我会在

<$ p中获得例外$ p> var exitCode = process.ExitCode;





例外情况是:

流程必须在请求之前退出信息可以确定。
解决方案


Hello
I have this method to execute commands

private static int ExecuteCommand(string command, int timeout)
       {
           var processInfo = new ProcessStartInfo("cmd.exe", "/C " + command)
           {
               CreateNoWindow = true,
               UseShellExecute = false,
               WorkingDirectory = "C:\\",
           };

           var process = Process.Start(processInfo);
           process.WaitForExit(timeout);
           var exitCode = process.ExitCode;
           process.Close();

           return exitCode;
       }



some times i get an exception in

var exitCode = process.ExitCode;



the exception is:

Process must exit before requested information can be determined.
解决方案


这篇关于进程访问超时时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 21:50
查看更多