private async void taskBtn1_Click (object sender, EventArgs e)
{
var t = Task.Run(() => {
Thread.Sleep(5000);
return "Hello I am TimeConsumingMethod";
});
//不阻塞主进程UI
textBox1.Text = await t;
//界面卡死5分钟
textBox1.Text = t.Result;
}
原文:https://www.cnblogs.com/yuchenghao/p/13290721.html