【问题标题】:C# - Redirect process output of game (UDK) serverC# - 重定向游戏(UDK)服务器的进程输出
【发布时间】:2015-05-14 13:14:47
【问题描述】:

我正在尝试重定向游戏服务器进程的输出,但我没有收到大部分输出。

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)
{
    ...
}

【问题讨论】:

    标签: c# process output server


    【解决方案1】:

    您还需要在输出某些内容时刷新输出缓冲区。如果不刷新,输出缓冲区可能会持续到外部进程退出;这使得主应用程序无法“实时”捕获输出

    【讨论】:

      猜你喜欢
      • 2011-09-30
      • 1970-01-01
      • 2013-09-06
      • 1970-01-01
      • 2013-02-01
      • 1970-01-01
      • 2013-08-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多