监视不一定使用 CR/LF 的过程标准输出
我的应用程序定期使用 process.start 启动控制台程序。 我需要“实时”监控程序的输出。
例如,程序将以下文本写入控制台: 处理中......
每隔一秒左右就会出现一个新点,让用户知道程序仍在处理中。 但是,...直到程序输出 CR/LF 之前,我无法检索程序的标准输出(当它仍在运行时)。
我该怎么做才能实时获取输出 - 比方说 - 将其通过管道传输到数据库(例如 VB.NET 中)?
My application periodically starts console programs with process.start. I need to monitor the output of the programs in "realtime".
For example, the program writes the following text to the console:
Processing.................
Every second or so a new dot appears to let the user know the program is still processing. However,... until the programm outputs a CR/LF, I am not able to retrieve the standard output of the program (while it is still running).
What can I do to get the output in realtime for - let's say - piping it into a database for instance in VB.NET?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将输出发送到文本文件并每秒读取该文件怎么样?
what about sending output into a text file and reading that file every second?
我很沮丧,因为我家里确实有一个原型应用程序做了类似的事情。 我看看能不能拿到。 同时查看此链接:
http: //msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput.aspx
它显示了如何将应用程序的输出重定向到自定义流,例如
上面是一个具有计时器的网络表单它用于轮询控制台的输出流并将其内容放入文本框中。 它不太有效(因此我想找到我的其他应用程序),但你明白了。
希望这可以帮助。
I'm gutted since I did have a prototype application at home that did something like this. I'll see if I can fetch it. In the meantime have a look at this link:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput.aspx
It shows how to redirect the output of applications to a custom stream e.g.
The above is a webform that has a timer which is used to poll the output stream of a console and get it's content into a textbox. It doesn't quite work (hence why I want to find my other app), but you get the idea.
Hope this helps.