c# 異步更新UI 不阻塞 流暢
Task task = Task.Factory.StartNew(() =>
{
DoLongRunningWork(); // 耗時運算
});
Task UITask= task.ContinueWith(() =>
{
this.TextBlock1.Text = "Complete"; //運算后 賦值
}, TaskScheduler.FromCurrentSynchronizationContext());
btnStop.Invoke(new Action(delegate() { this.btnStop.Enabled = false; }));
btnStart.Invoke(new Action(delegate() { this.btnStart.Enabled = true; }));
