I am trying to read the output of an external application using redirected
stdout and StreamReader::ReadLine(). The problem is that ReadLine() blocks
and I am either reading nothing or just part of the output.
I start a new process from my app to run the external app.
StartInfo.RedirectStandardOutput is set to true.
Then I start a thread that just keep reading the standard output of this new
process in an infinite loop using ReadLine().
When I try running it, ReadLine() blocks until I kill the external app
process. The external app is outputing something because I am running
another instance in a command prompt and I can see the output (running
multiple instances does not affect how the external app works).
If I put a breakpoint at the ReadLine() call and then step through it, it
will read some of the output but still block after a while. I tried using
TextReader.Synchronized() to get a thread-safe reader but it still blocks.
My understaning is that ReadLine() will block until a line is read but it
doesn't seem to work this way. How can I solve this problem?
Thanks.