我正在編寫一個應用程序,顯示您在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