2015-05-14 34 views
0

我試圖重定向遊戲服務器進程的輸出,但我沒有收到大部分輸出。C# - 重定向遊戲(UDK)服務器的進程輸出

Here's a image of what such a server looks like.

現在,我能夠接受的黃線,但一切只是沒有顯示出來,無論是在控制檯或在我的結束。

有什麼想法?

Process p = new Process(); 
p.StartInfo.FileName = file; 
p.StartInfo.Arguments = arguments; 
p.StartInfo.UseShellExecute = false; 
p.StartInfo.RedirectStandardOutput = true; 
p.StartInfo.RedirectStandardError = true; 
p.OutputDataReceived += new DataReceivedEventHandler(OutputHandler); 
p.ErrorDataReceived += new DataReceivedEventHandler(ErrorHandler); 

p.Start(); 
p.BeginOutputReadLine(); 
p.BeginErrorReadLine(); 

private void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine) 
{ 
    ... 
} 

private void ErrorHandler(object sendingProcess, DataReceivedEventArgs outLine) 
{ 
    ... 
} 

回答

0

您還需要在輸出內容時刷新輸出緩衝區。如果沒有刷新,輸出緩衝區會持續到外部進程退出;這使得主應用程序無法捕獲輸出「實時」