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 }"; }