wpf刷新线程控件值,可参考如下代码,改代码t1控件从0到49逐一递增:
private void Button_Click(object sender, RoutedEventArgs e)
{
new Thread(new ThreadStart(test)).Start();
}
public void test() {
for (int i = 0; i < 50; i++)
{
this.Dispatcher.Invoke(new Action(() =>
{
t1.Text = i;
}));
Thread.Sleep(200);
}
}