private void button1_Click(object sender, EventArgs e)
        {
            Task t1 = Task.Factory.StartNew(() => k1());
            Task t2 = Task.Factory.StartNew(() => k2());
        }
 
        void k1()
        {
            for (int i = 0; i < 100; i++)
            {
                Thread.Sleep(100);
                this.Invoke(new Action(
                    () => { this.label1.Text = i.ToString(); }));
            }
        }
 
        void k2()
        {
            for (int i = 0; i < 100; i++)
            {
                Thread.Sleep(100);
                this.Invoke(new Action(
                    () => { this.label2.Text = i.ToString(); }));
            }
        }

 

posted on 2019-01-08 15:44  天涯浪子1955  阅读(1360)  评论(0编辑  收藏  举报