如何在Windows Phone 8中将异步任务更改为同步?

时间:2014-12-18 07:53:26

标签: c# xaml windows-phone-8 asynchronous synchronous

当我使用此代码时,我能够获得结果

var photos = DataService.GetPhotos();
var groupedPhotos =
   from photo in photos
   orderby photo.TimeStamp
   group photo by photo.TimeStamp.ToString("y") into photosByMonth
   select new KeyedList<string, Photo>(photosByMonth);
GroupedPhotos = new List<KeyedList<string, Photo>>(groupedPhotos);

但是当我尝试使用这个

Deployment.Current.Dispatcher.BeginInvoke(() =>
{
    var photos = DataService.GetPhotos();
    var groupedPhotos =
        from photo in photos
        orderby photo.TimeStamp
        group photo by photo.TimeStamp.ToString("y") into photosByMonth
        select new KeyedList<string, Photo>(photosByMonth);

    GroupedPhotos = new List<KeyedList<string, Photo>>(groupedPhotos);

});

我无法得到我的结果,请建议!!

0 个答案:

没有答案