在 .NET 中有效地重定向标准输出 [英] Redirect Standard Output Efficiently in .NET
本文介绍了在 .NET 中有效地重定向标准输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从 .NET 程序调用 php-cgi.exe.我使用 RedirectStandardOutput 将输出作为流返回,但整个过程非常缓慢.
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 FilesApplicationphp"
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()
推荐答案
您可以使用 OutputDataReceived 事件 接收数据,因为它被泵送到 StdOut.
You can use the OutputDataReceived event to receive data as it's pumped to StdOut.
这篇关于在 .NET 中有效地重定向标准输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文