您的位置:首页 > 编程语言 > C#

C# 委托 Action<T>

2015-10-11 19:24 351 查看
Thread BackgroundThread;
private void button1_Click(object sender, EventArgs e)
{
if (BackgroundThread == null)
{
BackgroundThread = new Thread(new ThreadStart(ThreadMethod));
BackgroundThread.IsBackground = true;
BackgroundThread.Start();
}
}

void ThreadMethod()
{
int value = 0;
Action<int> UiDelegate = delegate(int DisValue)
{
label24.Text = DisValue.ToString();
};
while (true)
{
value++;
label24.Invoke(UiDelegate, value);
Thread.Sleep(1000);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: