我知道这个问题可能没有意义,我很难想象一个解释方式,所以我会展示一小段代码来帮助理解。我在使用Visual Studio Express 2010上的Winforms:
private void button1(object sender, EventArgs e)
{
txtOutput.Text += "Auto-collecting variables. This may take several minutes";
string v = foo();
txtOutput.Text += "\n" + v;
string b = bar();
txtOutput.Text += "\n" + b;
txtOutput.SelectionStart = txtOutput.Text.Length;
txtOutput.ScrollToCaret(); //scrolls to the bottom of textbox
}
基本上,当用户点击button1时,我希望“自动收集变量…”显示在文本框中,然后执行foo()函数,并将其显示出来,然后执行bar()函数,然后再将其显示出来。
目前的情况是,在foo()和bar()函数执行后一次性显示所有内容(这些函数需要几分钟的时间才能执行)。有没有办法解决这个问题,或者有没有解决方法?
编辑:C#的版本是4.0。如果我更新到4.5或5.0,那么没有安装.NET 4.5/5.0的计算机能否运行.exe文件?