WPF后台异步多线程更新UI控件

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;
            }));
        }

发布了181 篇原创文章 · 获赞 35 · 访问量 76万+

猜你喜欢

转载自blog.csdn.net/dacong/article/details/95391201