- android - AmazonSNS - AwsCredentials.properties - NullPointerException
- android - ListView invalidate() 与 invalidateViews() 之间的区别?
- android - 获取上下文的问题
- Android M 权限模型
我的程序一直运行良好,但突然卡在 Process.WaitForExit();而不继续执行下一个命令。我已经多次运行该程序而没有出现错误。有谁知道我该如何调试这个或者有谁知道背后的问题是什么?会不会是我的 python.exe 有问题?谢谢!
public static void Process(string location)
{
int ExitCode;
ProcessStartInfo ProcessInfo;
Process Process;
ProcessInfo = new ProcessStartInfo();
ProcessInfo.FileName = location;
ProcessInfo.Arguments = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) +
"\\parse.py " + Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\cache.cell";
ProcessInfo.CreateNoWindow = true;
ProcessInfo.UseShellExecute = false;
ProcessInfo.RedirectStandardOutput = true;
ProcessInfo.RedirectStandardError = true;
Process = Process.Start(ProcessInfo);
// (...)
Process.WaitForExit();
string stderr = Process.StandardError.ReadToEnd();
string stdout = Process.StandardOutput.ReadToEnd();
//Console.WriteLine("STDERR: " + stderr);
//Console.WriteLine("STDOUT: " + stdout);
using (System.IO.StreamWriter file = new System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\test.txt"))
{
file.WriteLine(stdout);
}
最佳答案
在进程退出之前,您的程序不会打印任何内容。如果进程永远不会退出,您将永远看不到任何东西,并且无法调试问题。
更好地打印出来
var info = new ProcessStartInfo("msbuild")
{
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardError = true,
RedirectStandardOutput = true,
};
using (var p = Process.Start(info) )
{
p.ErrorDataReceived += (s, e) => Console.Error.WriteLine(e.Data);
p.OutputDataReceived += (s, e) => Console.WriteLine(e.Data);
p.BeginErrorReadLine();
p.BeginOutputReadLine();
p.WaitForExit();
}
关于c# - 我的程序停留在 Process.WaitForExit();,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17674528/
这是我的代码 />100 1000 它不按要求工作.. 当提交表单时(并且在任何错误情况下)它返回到默认选中的单选按钮,即值 = 1000 用户必须再次单击值 = 100,而目标是,如果用户选择了 1
假设我有一个透明的红色 HTML 元素。当我悬停该元素时,它应该变成纯红色。当我停止悬停该元素时,它应该动画回到第一个状态,但仅在 X 秒后。 到目前为止一切顺利,请参阅代码片段。 我的问题是当我停止
我遇到了 cookie 情况,我的 cookie 会存储一个颜色名称或根本不存储任何内容。所以让我们这样解释吧。我的 cookie 与我网站的外观有关,我的网站有 3 种外观: 正常(完全没有 coo
这是我的问题。我有一张包含三个 div 的 Bootstrap v4 卡。 A 是最重要的一个,我希望它保持在左上角。 当页面较宽时,我希望 B 和 C 在 A 的右侧。 当页面变窄时,卡片缩小,C
示例表: uid time_stp traf 1 2016-01-13 00:00:00 6 1 2016-01-13 05:00:00 8 1
我是一名优秀的程序员,十分优秀!