本文整理汇总了C#中Windows.Invoke方法的典型用法代码示例。如果您正苦于以下问题:C# Windows.Invoke方法的具体用法?C# Windows.Invoke怎么用?C# Windows.Invoke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Windows
的用法示例。
在下文中一共展示了Windows.Invoke方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SearchAsync
public Task<List<FlickrImage>> SearchAsync(string searchTerm, Windows.UI.Core.CoreDispatcher dispatcher)
{
return Task.Run<List<FlickrImage>>(() =>
{
var flickrImages = new List<FlickrImage>();
var photos = _Flickr.PhotosSearch(new PhotoSearchOptions(this.Username, string.Empty, TagMode.None, searchTerm));
foreach (var photo in photos)
{
dispatcher.Invoke(Windows.UI.Core.CoreDispatcherPriority.Normal, (x, y) =>
{
flickrImages.Add(new FlickrImage(null, photo.SmallUrl, photo.DoesLargeExist ? photo.LargeUrl : photo.Medium640Url, photo.Title, photo.DateTaken));
},
this, null);
}
return flickrImages;
});
}
示例2: LoadAsync
public Task<IList<FlickrImageSet>> LoadAsync(Windows.UI.Core.CoreDispatcher dispatcher)
{
var task = Task.Run(() =>
{
var flickrUser = _GetUserProfileAsync(this.Username).Result;
var photoSetCollection = _GetPhotosetCollectionAsync(flickrUser.UserId).Result;
foreach (var photoSet in photoSetCollection)
{
FlickrImageSet imageSet = null;
dispatcher.Invoke(Windows.UI.Core.CoreDispatcherPriority.Normal, (x,y) =>
{
imageSet = new FlickrImageSet(photoSet.PhotosetSmallUrl, photoSet.Title, photoSet.DateUpdated, photoSet.Description);
this.ImageSets.Add(imageSet);
base.OnPropertyChanged("ImageSets");
},
this, null);
var photosetPhotosCollection = _GetCollectionForSetAsync(photoSet.PhotosetId).Result;
foreach (var photo in photosetPhotosCollection)
{
dispatcher.Invoke(Windows.UI.Core.CoreDispatcherPriority.Normal, (x,y) =>
{
var image = new FlickrImage(imageSet, photo.SmallUrl, photo.DoesLargeExist ? photo.LargeUrl : photo.Medium640Url, photo.Title, photo.DateTaken);
imageSet.Collection.Add(image);
},
this, null);
}
}
return this.ImageSets;
});
return task;
}
示例3: EnsureOnUI
private static async Task EnsureOnUI(Windows.UI.Core.DispatchedHandler callback)
{
if (App.Dispatcher.HasThreadAccess)
{
callback.Invoke();
}
else
{
await App.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, callback);
}
}