WPF後臺異步多線程更新UI控件
private void button_Click(object sender, RoutedEventArgs e)
{
new Thread(() =>
{
updatevalue(DateTime.Now.ToString(),20);
}).Start();
}
public void updatevalue(string id, int v)
{
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
{
label.Content = id; progressBar1.Value = v;
}));
}