[英]How to parse a third party console application showing the status of external process (C#)?
The following video (gif) shows a third party console application that is managing an external process.以下视频 (gif) 显示了管理外部进程的第三方控制台应用程序。
I'm looking to parse the information in the standard output to show it in a WinForm (C#).我正在寻找解析标准 output 中的信息以在 WinForm (C#) 中显示它。
I tried various approaches (for example here ) but none seems to work, meaning nothing in the StreamReader, neither OutputDataReceived event.我尝试了各种方法(例如here ),但似乎都不起作用,这意味着 StreamReader 中没有任何内容,也没有 OutputDataReceived 事件。
If the text have new line characters, there is not issue.如果文本有换行符,则没有问题。 But is not the case with this app.
但这个应用程序并非如此。
Any advice is appreciated.任何建议表示赞赏。
Thanks谢谢
It may depend on the operating system.它可能取决于操作系统。 But it looks like the line gets rewritten .
但看起来这条线被重写了。 In this case you would need to read the stream buffer before it gets "committed" by a newline.
在这种情况下,您需要在 stream 缓冲区被换行符“提交”之前读取它。 (As you found out. IISC, the answer you linked uses BeginOutput ReadLine .) So, when you have your stream (eg standard input ?) You might be able to read the buffer more precisely .
(正如您所发现的。IISC,您链接的答案使用 BeginOutput ReadLine 。)因此,当您拥有 stream (例如标准输入?)您可能能够更精确地读取缓冲区。
Hope, I got the question right:)希望,我的问题是对的:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.