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)); }
private async Task <Headline[]> FetchHeadlinesTaskAsync(NewsSource newsSource) { string rawData = await new WebClient().DownloadStringTaskAsync(newsSource.Url); return(ParserUtils.ExtractHeadlines(newsSource, rawData)); }