예제 #1
0
        public async Task <ActionResult> FetchAsynchronously()
        {
            var resultItems = new List <Headline>();

            foreach (var newsSource in _newsSources)
            {
                string rawData = await new WebClient().DownloadStringTaskAsync(newsSource.Url);
                resultItems.AddRange(ParserUtils.ExtractHeadlines(newsSource, rawData));
            }

            return(View("results", resultItems));
        }
예제 #2
0
        private async Task <Headline[]> FetchHeadlinesTaskAsync(NewsSource newsSource)
        {
            string rawData = await new WebClient().DownloadStringTaskAsync(newsSource.Url);

            return(ParserUtils.ExtractHeadlines(newsSource, rawData));
        }