Пример #1
0
        public void LoadFeedAsync2()
        {
            IsLoading = true;

            var feedClient      = new HeiseFeedClient();
            var loadingFeedTask = feedClient.DownloadFeedAsync(_cancellationToken.Token);

            loadingFeedTask.ContinueWith(t => PopulateViewModel(t.Result), CancellationToken.None,
                                         TaskContinuationOptions.OnlyOnRanToCompletion,
                                         TaskScheduler.FromCurrentSynchronizationContext());
            loadingFeedTask.ContinueWith(HandleProblem, CancellationToken.None,
                                         TaskContinuationOptions.NotOnRanToCompletion,
                                         TaskScheduler.FromCurrentSynchronizationContext());
        }
Пример #2
0
        public async Task LoadFeedAsync()
        {
            IsLoading = true;

            var feedClient = new HeiseFeedClient();

            try
            {
                var loadedFeeds = await feedClient.DownloadFeedAsync(_cancellationToken.Token);

                var parsedFeeds = loadedFeeds.Select(f => new FeedEntryViewModel(f));
                Feeds = new ObservableCollection <FeedEntryViewModel>(parsedFeeds);
            }
            catch (AggregateException ex)
            {
                MessageBox.Show(ex.InnerExceptions[0].Message);
            }
            finally
            {
                IsLoading = false;
            }
        }