StreamReader problem. What am I doing wrong?



I'm trying to build an app (in VB.Net) that will interact with various
console applications. It's interaction is pretty simple. It will just send
commands to the standard input stream, and retrieve output from the standard
output and standard error streams. The trickiness comes from the fact that
it must be a multithreaded app to do this properly, and while I think I have
it set up correctly, I'm having a problem getting the output from the
standard output stream. I set the UseShellExecute property of the process to
false, and redirected standardinput, standardoutput and standarderror. I
spawn threads to listen to the two output streams. Here's the sub that is
passed to the thread and does the listening to standardoutput (Sreader is the
standardoutput stream):

Public Sub Read()
Dim val As Integer

While ((val = Sreader.Read()) >= 0)
RaiseEvent ReadStreamCompleted(Me, New
ReadStreamEventArgs(Chr(val).ToString, strName))
End While

End Sub


That's it. Now, all it returns is zeros. But it DOES return the proper
number of zeros to match the number of expected characters in the output. I
have no idea why that is. Can anyone tell me what I'm doing wrong here? I
can't find anything more than the most simplistic examples of interacting
with console apps on the web, and all the books I've looked in haven't been
much more helpful either.

Nothing seems to explain how to simply return all the output that a console
app generates, basically in real time, until the application closes. That's
what I need. Any help is appreciated. Thanks!
.



Relevant Pages

  • Re: How create a console using java graphical interface
    ... java.lang.System.setOutand java.lang.System.setErrwill allow you to change standard output and standard error streams to something else, ... Even though your application uses a GUI, the console streams are still there. ... open a command line window and run your app from the command line. ...
    (comp.lang.java.programmer)
  • Problems reading StandardOutput and StandardError at runtime
    ... I've recently discovered the value of using existing console ... this console app and update my UI to show it's still working. ... To sum up, I call read on either standarderror or standardoutput, I've ... stream buffer and blocking the other. ...
    (microsoft.public.dotnet.csharp.general)
  • Problems reading StandardOutput and StandardError at runtime
    ... I've recently discovered the value of using existing console ... this console app and update my UI to show it's still working. ... To sum up, I call read on either standarderror or standardoutput, I've ... stream buffer and blocking the other. ...
    (microsoft.public.dotnet.general)
  • Re: No, POLL and WAIT
    ... > The WaitForSingleObjectEx function returns when one of the following ... Yes, you can wait on a file handle that refers to a console, and yes in many ... > The GetStdHandle function returns a handle for the standard input, ... or by the GetStdHandle function. ...
    (alt.lang.asm)
  • Re: CR-NL, NL and ftell
    ... a program capable of both card and tape output ... > the keyboard was not part of standard C! ... from any input source: ... if you use a text stream to read the data back again: ...
    (comp.lang.c)