I am trying to interact with a process that I am running via StandardOutput and StandardInput. For the most part it works well, but I find myself needing a way to clear out any "to be read" lines in the StandardOutput (prior to sending a command that will generate new lines in StandardOutput).
I had hoped to use StandardOutput.EndOfStream, but it just hangs when checked.
That question has the suggestions to use BeginOutputReadLine for reading from the stream, but an event system like that will really complicate my code. I would rather keep it synchronous. (I send a command and read the response right then.) (I know that async is usually better, but I am already on a background thread that I just want to block until the back and forth between the child process is done.)
Is there some other way to know if there are unread lines waiting for me in a StandardOutput stream?