我有一個基本的Winform,調用外部程序(SVN)。我想在窗體的文本框中顯示SVN產生的輸出。刷新窗體控件與外部程序輸出
這裏是我的調用這個外部的程序代碼:
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();
}
這就是所謂的一個「的foreach」裏。問題是,當我啓動命令時,我必須等到每一個命令都完成了......這可能需要很長時間。在此期間,表單凍結,並且文本框中不顯示任何內容。
也許使用這種方法,儘管有WaitForExit,同時啓動這些命令?我不確定,我不熟悉這類問題(我更像是一名Web開發人員)。
如何在程序運行時顯示SVN輸出並阻止表單凍結?
謝謝
謝謝,但我該怎麼做? – thomasb 2009-12-10 12:11:12