110,499
社区成员
发帖
与我相关
我的任务
分享
private void button1_Click(object sender, RoutedEventArgs e)
{
tm.Start();
progbar.Value = 0;
progbar.Maximum = 100;
tm_Tick(sender, e);
for (int i = 0; i < 1000000; i++)
{
string passedSns = i + Environment.NewLine + this.textBox1.Text;
this.textBox1.Text = passedSns;
textBox1.Foreground = new SolidColorBrush(Colors.Red);
}
}
private void button1_Click(object sender, RoutedEventArgs e)
{
Thread thread = new Thread(new ThreadStart(Run));
thread.IsBackground = true;
thread.Start();
}
public void Run()
{
for (int i = 0; i < 1000; i++)
{
this.Dispatcher.BeginInvoke((Action)delegate()
{
string passedSns = i + Environment.NewLine + this.textBox1.Text;
this.textBox1.Text = passedSns;
textBox1.Foreground = new SolidColorBrush(Colors.Red);
});
//给界面更新TextBox的时间
Thread.Sleep(10);
}
}