Winform如何不阻塞主进程UI的同时操作其他控件的输出
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;
}