我正在编写一个应用程序,显示您在Ethereum(像比特币这样的加密货币)中的当前哈希率,并且我需要以某种方式从正在运行的命令行获取连续输出。这是我到目前为止,但它不打印到程序输出:C#WPF读取控制台输出
pProcess.OutputDataReceived += new DataReceivedEventHandler((sender, e) =>
{
// Prepend line numbers to each line of the output.
if (!String.IsNullOrEmpty(e.Data))
{
System.Console.Write(e.Data);
}
});
//Wait for process to finish
pProcess.WaitForExit();
什么是不适用于此代码?我猜测事件处理程序有些东西搞砸了,但我不知道是什么。
你打电话的任何进程?像Process aNewProcess = new Process(); – bluetoothfx
很难说这里发生了什么,代码不多。 –
我想你需要给我们更多的细节。如果你能够。 – bluetoothfx