private void RunDownloadSync() { List <string> webUrl = WebsiteList(); foreach (var item in webUrl) { WebsiteDataModel wdm = DownloadSite(item); ReportWebsiteInfo(wdm); } }
private WebsiteDataModel DownloadSite(string webUrl) { WebsiteDataModel wdm = new WebsiteDataModel(); WebClient clnt = new WebClient(); wdm.WebsiteUrl = webUrl; wdm.WebsiteData = clnt.DownloadData(webUrl); return(wdm); }
private void RunDownloadSync() { List <string> websites = PrepData(); foreach (string site in websites) { WebsiteDataModel results = DownloadWebsite(site); ReportWebsiteInfo(results); } }
private async Task <WebsiteDataModel> DownloadSiteAsync(string webUrl) { WebsiteDataModel wdm = new WebsiteDataModel(); WebClient clnt = new WebClient(); wdm.WebsiteUrl = webUrl; wdm.WebsiteData = await clnt.DownloadDataTaskAsync(webUrl); return(wdm); }
private async Task <WebsiteDataModel> DownloadWebsiteAsync(string websiteURL) { var output = new WebsiteDataModel(); var client = new WebClient(); output.WebsiteUrl = websiteURL; output.WebsiteData = await client.DownloadStringTaskAsync(websiteURL); return(output); }
private WebsiteDataModel DownloadWebsite(string websiteURL) { var output = new WebsiteDataModel(); var client = new WebClient(); output.WebsiteUrl = websiteURL; output.WebsiteData = client.DownloadString(websiteURL); return(output); }
private async Task RunDownloadAsync() { List <string> webUrl = WebsiteList(); foreach (var item in webUrl) { WebsiteDataModel wdm = await Task.Run(() => DownloadSite(item)); ReportWebsiteInfo(wdm); } }
private async Task RunDownloadAsync() { List <string> websites = PrepData(); foreach (string site in websites) { WebsiteDataModel results = await Task.Run(() => DownloadWebsite(site)); ReportWebsiteInfo(results); } }
private async Task RunDownloadAsync(IProgress <ProgressReportModel> progress, CancellationToken ct) { List <string> webUrl = WebsiteList(); ProgressReportModel prm = new ProgressReportModel(); int i = 0; foreach (var item in webUrl) { ct.ThrowIfCancellationRequested(); WebsiteDataModel wdm = await Task.Run(() => DownloadSite(item)); i += 1; //ReportWebsiteInfo(wdm); prm.sitesDownloaded = wdm; prm.Percentage = (i * 100) / webUrl.Count; progress.Report(prm); } }
private void ReportWebsiteInfo(WebsiteDataModel wdm) { txtResults.Text += "\r\n Downloaded " + wdm.WebsiteUrl + " , Size is: " + wdm.WebsiteData.Length.ToString(); }
private void ReportWebsiteInfo(WebsiteDataModel data) { resultsWindow.Text += $"{ data.WebsiteUrl } downloaded: { data.WebsiteData.Length } characters long. { Environment.NewLine }"; }