private void RunDownloadSync() { List <string> websites = PrepData(); foreach (string site in websites) { WebsiteDataModel results = DownloadWebsite(site); ReportWebsiteInfo(results); } }
private async Task <WebsiteDataModel> DownloadWebsiteAsync(string websiteURL) { WebsiteDataModel output = new WebsiteDataModel(); WebClient client = new WebClient(); output.WebsiteUrl = websiteURL; output.WebsiteData = await client.DownloadStringTaskAsync(websiteURL); return(output); }
private WebsiteDataModel DownloadWebsite(string websiteURL) { WebsiteDataModel output = new WebsiteDataModel(); WebClient client = new WebClient(); output.WebsiteUrl = websiteURL; output.WebsiteData = client.DownloadString(websiteURL); return(output); }
private async Task RunDownloadAsync() { List <string> websites = PrepData(); foreach (string site in websites) { WebsiteDataModel results = await Task.Run(() => DownloadWebsite(site)); ReportWebsiteInfo(results); } }
private void ReportWebsiteInfo(WebsiteDataModel data) { resultsWindow.Text += $"{ data.WebsiteUrl } downloaded: { data.WebsiteData.Length } characters long.{ Environment.NewLine }"; }