标签:
界面假死的代码:
void btnSecondEventMode_Click(object sender, EventArgs e) { btnSecondEventMode.BackColor = Color.Coral; Thread.Sleep(5000); MessageBox.Show("hello world"); }
WinForm 异步调用
void BtnSecondEventAsyncModel_Click(object sender, EventArgs e) { Action action = () => { Task.Run(() => { BtnSecondEventAsyncModel.BackColor = Color.Coral; Thread.Sleep(5000); MessageBox.Show("hello world"); }); }; BeginInvoke(action); }
WPF 异步调用
void BtnSecondEventAsyncModel_Click(object sender, EventArgs e) { Action action = () => { Task.Run(() => { BtnSecondEventAsyncModel.BackColor = Color.Coral; Thread.Sleep(5000); MessageBox.Show("hello world"); }); }; Dispatcher.BeginInvoke(action); }
标签:
原文地址:http://www.cnblogs.com/aquarius20th/p/4977718.html