弹来弹去跑马灯!

c# 多线程和异步

有时候需要多线程来运行处理后端和UI的更新。

通常用

 

 ((Action)delegate()
            {
                if (isBussy) { return; }
                isBussy = true;
                while (true)
                {
                    //code long time task.................

                    Dispatcher.BeginInvoke((Action)(delegate()
            {
                btnStart.Content = DateTime.Now.ToString();
            }
             ));



                    Thread.Sleep(300);
                }

                isBussy = false;

            }).BeginInvoke(null, null);


         

  

posted @ 2018-07-03 17:32  wgscd  阅读(287)  评论(0)    收藏  举报