日期:2014-05-18 浏览次数:20854 次
private void button1_Click(object sender, EventArgs e) { Thread th = new Thread(new ThreadStart(Test)); th.Start(); } public void Test() { for (int i = 0; i <= 20; i++) { for (int j = 0; j < 100; j++) { ViewLable(i.ToString()+"-"+j.ToString()); } } } public delegate void ViewLableDelegate(string str);//定义一个委托 public void ViewLable(string str) { if (label1.InvokeRequired) { ViewLableDelegate wmd = new ViewLableDelegate(ViewLable);//应该是这样,楼上是我代码复制过来的,不好意思 label1.Invoke(wmd, new string[] { str }); } else { label1.Text = str; } }