Hello
I have a basic winform, calling an external program (SVN). I want to display the output produced by SVN in a textbox in the form.
Here is my code for calling this external program :
private void SVNcmd(string args, string workingcopy)
{
textBoxOutput.Text += workingcopy + Environment.NewLine
+ args + Environment.NewLine;
Process p = new Process();
p.StartInfo.WorkingDirectory = workingcopy;
p.StartInfo.FileName = "svn";
p.StartInfo.Arguments = args;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.Start();
textBoxOutput.Text += p.StandardOutput.ReadToEnd() + Environment.NewLine;
p.WaitForExit();
}
It's called inside a "foreach". The problem is, when I launch the command, I have to wait until each and every command has been finished... and it can take quite a while. During this time, the form freezes, and nothing is displayed in the textbox.
Maybe with this method the commands are launched at the same time, despite the WaitForExit ? I'm not sure, I'm not familiar with this type of problems (I'm more of a web developer).
What can I do to display the SVN output and stop the form from freezing while the program runs ?
Thanks