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; }));

 

 

 

相关文章:

  • 2021-12-03
  • 2021-10-17
  • 2021-09-25
  • 2021-09-18
  • 2021-11-01
猜你喜欢
  • 2021-08-18
  • 2021-11-13
  • 2021-08-01
  • 2021-11-18
  • 2021-07-26
  • 2021-09-15
相关资源
相似解决方案