M
Matt Burland
I'm having a problem with redirecting the StandardOutput of a process that I
use to run a DOS program in my application. The problem is that I when I
start my process (which I do in a separate thread) I can't read anything
from the stdout before the process actually finishes. If I do something like
this:
Process myProcess = new Process(myStartInfo)
// this gets shown straight away
MessageBox.Show("Process Started");
string s = myProcess.StandardOutput.Readline();
// this doesn't get shown until the process has finished
MessageBox.Show(s);
myProcess.WaitForExit();
// this gets shown immediately following the last MessageBox
MessageBox.Show("Process Finished");
It's clear that I'm not reading anything from the stdout before the process
has finished. This is a problem because the program I am running transfers
files to a server and can take a long time to finish, but I'm unable to give
the user any information about what is going on during the transfer.
Can somebody please tell me how to read the stdout without hanging up things
up until the process has finished? I can't believe there isn't a way to do
this!!
Cheers
use to run a DOS program in my application. The problem is that I when I
start my process (which I do in a separate thread) I can't read anything
from the stdout before the process actually finishes. If I do something like
this:
Process myProcess = new Process(myStartInfo)
// this gets shown straight away
MessageBox.Show("Process Started");
string s = myProcess.StandardOutput.Readline();
// this doesn't get shown until the process has finished
MessageBox.Show(s);
myProcess.WaitForExit();
// this gets shown immediately following the last MessageBox
MessageBox.Show("Process Finished");
It's clear that I'm not reading anything from the stdout before the process
has finished. This is a problem because the program I am running transfers
files to a server and can take a long time to finish, but I'm unable to give
the user any information about what is going on during the transfer.
Can somebody please tell me how to read the stdout without hanging up things
up until the process has finished? I can't believe there isn't a way to do
this!!
Cheers