问题
I'm writing a C# GUI Wrapper that wraps around an executable (which I CAN NOT modify because I do not have the source code). The problem I'm facing appears to be related to the fact the executable output does not end with a 'newline' character.
Instead, the .exe starts work and expects user input (s=status, q=quit, etc..).
I've spent a lot of time researching various ways to read StdOut, one with Asynchronous reads and listening for events, and the other method was with separate threads polling StdOut and StdErr and raising events to the UI thread which is updating the textbox.
Unfortunately, neither of these two methods seem to work since in both cases - the process does not raise events until the last line of output (one which has no 'newline' at the end), which is only displayed when the application closes.
Also, I can't seem to be able to send commands to it either by writing to it's StandardInput. I've followed the typical advice of disabling ShellExecute, Redirecting Input, etc...
I tried sending both a string, a char, a hex-representation of a char both as Write() and WriteLine(), and neither of those appear to work.
Any ideas?
来源:https://stackoverflow.com/questions/8625443/reading-standard-output-from-a-command-line-process-without-newline