在.NET高效标准输出重定向 [英] Redirect Standard Output Efficiently in .NET

查看:148
本文介绍了在.NET高效标准输出重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从.NET程序中调用名为php-cgi.exe。我用RedirectStandardOutput得到输出回为一个流,但整个事情是很慢的。

你对我怎么可以做出更快的任何想法?任何其他技术?

 昏暗oCGI作为的ProcessStartInfo =新的ProcessStartInfo()
    oCGI.WorkingDirectory =C:\ Program Files文件\应用程序\ PHP
    oCGI.FileName =名为php-cgi.exe
    oCGI.RedirectStandardOutput = TRUE
    oCGI.RedirectStandardInput = TRUE
    oCGI.UseShellExecute =假
    oCGI.CreateNoWindow = TRUE

    昏暗oProcess随着工艺=新工艺()

    oProcess.StartInfo = oCGI
    oProcess.Start()

    oProcess.StandardOutput.ReadToEnd()
 

解决方案

您可以使用<一个href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.outputdatareceived.aspx">OutputDataReceived因为它的泵到stdout事件接收数据。

I am trying to call php-cgi.exe from a .NET program. I use RedirectStandardOutput to get the output back as a stream but the whole thing is very slow.

Do you have any idea on how I can make that faster? Any other technique?

    Dim oCGI As ProcessStartInfo = New ProcessStartInfo()
    oCGI.WorkingDirectory = "C:\Program Files\Application\php"
    oCGI.FileName = "php-cgi.exe"
    oCGI.RedirectStandardOutput = True
    oCGI.RedirectStandardInput = True
    oCGI.UseShellExecute = False
    oCGI.CreateNoWindow = True

    Dim oProcess As Process = New Process()

    oProcess.StartInfo = oCGI
    oProcess.Start()

    oProcess.StandardOutput.ReadToEnd()

解决方案

You can use the OutputDataReceived event to receive data as it's pumped to StdOut.

这篇关于在.NET高效标准输出重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆