我有这个:
BusyState.SetBusy("Updating Calendar Data");
Dispatcher.CurrentDispatcher.Invoke(new Action(async () =>
{
// calling "update" will hit servers outside my control and may take time
await PublicCalendars.Update();
await PrivateCalendars.Update();
// clearing the busy state should only happen when both update tasks are finished
BusyState.ClearBusy();
}));
变量 PublicCalendars 和 PrivateCalendars 都在扩展 ObservableCollection 并在调用更新期间填充。集合绑定到某些 WPF GUI,因此必须从 UI 线程添加项目。
我想删除等待并让两个调用同时运行。当两个任务都完成时,我怎样才能做到这一点并且仍然清楚我的忙碌状态?