码迷,mamicode.com
首页 > Windows程序 > 详细

C# 委托 Action<T>

时间:2015-10-11 21:11:37      阅读:204      评论:0      收藏:0      [点我收藏+]

标签:

 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         }

 

C# 委托 Action<T>

标签:

原文地址:http://www.cnblogs.com/vhuichen/p/4869826.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!