我正在使用下面的代码绑定来自ObservableCollection的ItemsSource
Services.RestServices.GetNotifications(UserID, ++Page).ContinueWith((task) =>
{
Dispatcher.BeginInvoke((Action)(() =>
{
setNotListToBind(task.Result).ContinueWith(t =>
{
Dispatcher.BeginInvoke((Action)(() =>
{
var list = getFilteredNotList(notList, NotificationCategories.requests);
Dispatcher.BeginInvoke(() => NotificationContainer.ItemsSource = list;);
}));
});
}));
});在上面的代码中,我使用task-parallel-library等待执行,并在其中绑定itemsSource和dispature,但绑定后UI不更新。
这里我的itemsSource是NotificationContainer,ObservableCollection是list
发布于 2013-07-15 06:38:38
如果您知道Services.RestServices.GetNotifications是从UI线程调用的,那么可以通过在每次使用TaskScheduler.FromCurrentSyncronizationContext调用ContinueWith时指定TaskScheduler实例来简化代码。也许这可以帮助您更好地找到问题所在。
https://stackoverflow.com/questions/17596914
复制相似问题