0

The following video (gif) shows a third party console application that is managing an external process.

enter image description here

I'm looking to parse the information in the standard output to show it in a WinForm (C#).

I tried various approaches (for example here) but none seems to work, meaning nothing in the StreamReader, neither OutputDataReceived event.

If the text have new line characters, there is not issue. But is not the case with this app.

Any advice is appreciated.

Thanks

JACB
  • 33
  • 5
  • Use ReadLine() so you wait until you get an entire line before doing any processing. – jdweng Jun 16 '20 at 16:19
  • Hi @jdweng, thanks for your feedback. I tried your suggestion but the application is not sending the "end of line" character in order to allow ReadLine or OutputDataReceived work properly – JACB Jun 16 '20 at 16:42
  • It there a different terminating character? – jdweng Jun 16 '20 at 16:49
  • I don't know because I don't have the source code. Perhaps similar approaches as described in https://stackoverflow.com/questions/888533/how-can-i-update-the-current-line-in-a-c-sharp-windows-console-app – JACB Jun 16 '20 at 17:05
  • Then reverse engineer the data. Capture data and put into text (hex) so you can resolve the issue. – jdweng Jun 16 '20 at 18:24
  • See [this answer](https://stackoverflow.com/a/415655/2330053). – Idle_Mind Jun 16 '20 at 18:48
  • Not quite sure what you mean by reverse engineer the data. – JACB Jun 16 '20 at 19:35
  • @Idle_Mind, thanks for your feedback. That proposal works only when there is new line character. Already tried. – JACB Jun 16 '20 at 19:56

1 Answers1

0

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. (As you found out. IISC, the answer you linked uses BeginOutputReadLine.) So, when you have your stream (e.g. standard input?) You might be able to read the buffer more precisely.

Hope, I got the question right :)

AyJayKay
  • 103
  • 6