Complete() публичный Метод

Completes the associated task with the specified error.
public Complete ( Exception error ) : void
error Exception The error that occurred while completing the task.
Результат void
Пример #1
0
        public Async<Profile> GetProfile(string userName)
        {
            Async<Profile> asyncProfile = new Async<Profile>();

            _twitterService.GetProfile(userName, delegate(Profile profile) {
                if (profile == null) {
                    asyncProfile.Complete(new Exception("The profile for '" + userName + "' could not be loaded."));
                }
                else {
                    asyncProfile.Complete(profile);
                }
            });

            return asyncProfile;
        }
Пример #2
0
        public Async<IEnumerable> GetTweets(string userName)
        {
            Async<IEnumerable> asyncTweets = new Async<IEnumerable>();

            _twitterService.GetTweets(userName, delegate(IEnumerable<Tweet> tweets) {
                if (tweets == null) {
                    asyncTweets.Complete(new Exception("Favorites for '" + userName + "' could not be loaded."));
                }
                else {
                    IEnumerable<TweetGroup> groupedTweets =
                        tweets.AsQueryable().
                        OrderByDescending(t => t.Date).
                        GroupByContiguous<Tweet, int, TweetGroup>(
                            t => TweetGroup.GetDaysGroupValue(t),
                            EqualityComparer<int>.Default,
                            (t, d) => new TweetGroup(t, d));

                    asyncTweets.Complete(groupedTweets);
                }
            });

            return asyncTweets;
        }