标签:
1 Thread BackgroundThread; 2 private void button1_Click(object sender, EventArgs e) 3 { 4 if (BackgroundThread == null) 5 { 6 BackgroundThread = new Thread(new ThreadStart(ThreadMethod)); 7 BackgroundThread.IsBackground = true; 8 BackgroundThread.Start(); 9 } 10 } 11 12 void ThreadMethod() 13 { 14 int value = 0; 15 Action<int> UiDelegate = delegate(int DisValue) 16 { 17 label24.Text = DisValue.ToString(); 18 }; 19 while (true) 20 { 21 value++; 22 label24.Invoke(UiDelegate, value); 23 Thread.Sleep(1000); 24 } 25 }
标签:
原文地址:http://www.cnblogs.com/vhuichen/p/4869826.html