Hi,
I'm running a command line process from my C# application trying to catch
the output messages from the process into a textbox in my windows form. But
the text doesn't update (the ReadLine doesn't return) until the process
exits??? Any help is highly appreciated! The code is like this:
Process myProcess = new Process();
myProcess.StartInfo.FileName = Application.StartupPath +
"\\myCmdLine.exe";
myProcess.StartInfo.WorkingDirectory = Application.StartupPath;
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.CreateNoWindow = true;
myProcess.StartInfo.RedirectStandardOutput = true;
Thread processThread;
//.
//.
private void buttonStartProcess_Click(object sender, EventArgs e)
{
processThread = new Thread(new ThreadStart(runProcess));
processThread.IsBackground = true;
processThread.Start();
}
private void runProcess()
{
string data;
myProcess.Start();
while ((data = myProcess.StandardOutput.ReadLine()) != null)
{
UpdateTextBox(textBoxMessage, data); // this is a call to an
invoke function
}
}
Thanks,
Ole