[英]Textbox won't update to process output, but ShowMessage will (C#)
代码摘录:
ProcessStartInfo download = new ProcessStartInfo("CMD.exe", strCmdText);
download.UseShellExecute = false;
download.RedirectStandardOutput = true;
download.CreateNoWindow = true;
var proc = Process.Start(download);
while (proc.StandardOutput.EndOfStream)
{
string line = proc.StandardOutput.ReadLine();
outputBox.Clear();
outputBox.Text = line;
}
如果我有MessageBox.Show(line)
; 而不是outputBox.Text = line
;,它工作正常,并且每次我按确定时都会更新。 在过程完成之前,我将如何更新它?
尝试添加此命令:
string line = proc.StandardOutput.ReadLine();
outputBox.Clear();
outputBox.Text = line;
outputBox.Refresh();
Application.DoEvents();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.