【发布时间】:2021-04-21 17:56:44
【问题描述】:
我创建了一个应用程序来打开 AutoCAD Core Console 以向其写入一些命令。问题是单个线程的空闲 CPU 使用率为 100%。我发现 RedirectStandardInput 属性在设置为 true 时会执行此操作。当我将其设置为 false 时,空闲 CPU 使用率为 0.1%。我需要的是能够向控制台写入命令,当一切都完成后,空闲速度恢复到 0.1% 的 CPU 使用率。为什么会发生这种情况,我该如何解决?
// Set up process
coreprocess.StartInfo.Arguments = "/isolate";
coreprocess.StartInfo.UseShellExecute = false;
coreprocess.StartInfo.CreateNoWindow = true;
coreprocess.StartInfo.RedirectStandardOutput = false;
coreprocess.StartInfo.RedirectStandardError = false;
coreprocess.StartInfo.RedirectStandardInput = true;
coreprocess.StartInfo.FileName = installpath;
// Start Process
this.ConsoleStarted = coreprocess.Start();
【问题讨论】: