Lambda表达式的使用

来源:互联网 发布:vb和vf的区别 编辑:程序博客网 时间:2024/04/29 02:59

delegate void Shows(string str, Label lbl);
        private void button1_Click(object sender, EventArgs e)
        {
           
Thread thread = new Thread(()=> {
                for (int i = 0; i < 1000; i++)
                {
                    lblGo(i + "/1000", label1);
                    Thread.Sleep(100);
                }
                
            });

            thread.Start();
        }
        private void lblGo(string  j, Label lbl)
        {
            if (lbl.InvokeRequired)
            {
                Shows s = new Shows(lblGo);
                this.Invoke(s, new object[] { j, lbl });
            }
            else
            {
                lbl.Text = j;
            }
        }
原创粉丝点击