async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { BlogPosts.Clear(); var items = await BlogStore.GetItemsAsync(); foreach (var item in items) { BlogPosts.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public async Task OnItemSelectedAsync(SiteModel model) { if (model != null) { BlogPosts.Clear(); ButtonText = "Update Site"; Url = model.Url; Name = model.Name; Id = model.Id; Priority = model.Priority; FeedService service = new FeedService(); var(feedModel, error) = await service.FetchAsync(model.Url); if (feedModel != null) { BlogTitle = feedModel.Title; BlogPosts.Clear(); foreach (FeedItemModel item in feedModel.Items) { BlogPosts.Add(item); } } else { var psi = new ProcessStartInfo { FileName = model.Url, UseShellExecute = true }; Process.Start(psi); NotificationBackground = Brushes.Red; NotificationText = error; ShowNotification = Visibility.Visible; await Task.Factory.StartNew( async() => { await Task.Delay(2000); NotificationBackground = Brushes.Green; NotificationText = string.Empty; ShowNotification = Visibility.Collapsed; } ); } } }