WinForm异步更新界面

this.Invoke((MethodInvoker)delegate { textBox1.AppendText(tmp + "\r\n"); });

  

Action act = () =>
            {
                txt.AppendText(value);
            };

            if (txt.InvokeRequired) //非当前线程
                txt.Invoke(act);
            else
                act();

  

label1.Invoke((Action)(() => { label1.Text = "执行完毕!"; }));//这里跨线程访问UI需要做处理

  

posted @ 2017-11-23 11:51  chy710  阅读(10)  评论(0)    收藏  举报