[英]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.