public static void RunDownloadSync(IProgress <ProgressModel> progress) { List <string> websites = PrepData(); foreach (string site in websites) { WebsiteDataModel results = DownloadWebsite(site); } }
private static void TaskDone(Task <WebsiteDataModel> arg) { _doneSiteCont++; if (_progress != null) { ProgressModel progressModel = new ProgressModel(); progressModel.Progess = _doneSiteCont * 100 / _totalSiteCount; WebsiteDataModel data = arg.Result; progressModel.WebSiteStatus = $"{ data.WebsiteUrl } downloaded: { data.WebsiteData.Length } characters long in {data.time_ms} ms .{ Environment.NewLine }"; _progress.Report(progressModel); } }
public static async Task <WebsiteDataModel> DownloadWebsiteAsync(string websiteURL) { WebsiteDataModel output = new WebsiteDataModel(); WebClient client = new WebClient(); output.WebsiteUrl = websiteURL; var watch = System.Diagnostics.Stopwatch.StartNew(); output.WebsiteData = await client.DownloadStringTaskAsync(websiteURL); watch.Stop(); output.time_ms = watch.ElapsedMilliseconds; return(output); }
public static WebsiteDataModel DownloadWebsite(string websiteURL) { WebsiteDataModel output = new WebsiteDataModel(); WebClient client = new WebClient(); var watch = System.Diagnostics.Stopwatch.StartNew(); output.WebsiteUrl = websiteURL; output.WebsiteData = client.DownloadString(output.WebsiteUrl); watch.Stop(); output.time_ms = watch.ElapsedMilliseconds; return(output); }
public static void DownloadWebsite(string websiteURL, IProgress <ProgressModel> progress) { WebsiteDataModel output = new WebsiteDataModel(); WebClient client = new WebClient(); output.WebsiteUrl = websiteURL; var watch = System.Diagnostics.Stopwatch.StartNew(); output.WebsiteData = client.DownloadString(websiteURL); watch.Stop(); output.time_ms = watch.ElapsedMilliseconds; _doneSiteCont++; ProgressModel progressModel = new ProgressModel(); progressModel.Progess = _doneSiteCont * 100 / _totalSiteCount; progressModel.WebSiteStatus = $"{ websiteURL } downloaded: { output.WebsiteData.Length } characters long in {output.time_ms} ms .{ Environment.NewLine }"; _progress.Report(progressModel); }
private void ReportWebsiteInfo(WebsiteDataModel data) { resultsWindow.Text += $"{ data.WebsiteUrl } downloaded: { data.WebsiteData.Length } characters long in {data.time_ms} ms .{ Environment.NewLine }"; }
public static async Task DownloadWebsiteAddToListAsync(string websiteURL) { WebsiteDataModel websiteDataModel = await DownloadWebsiteAsync(websiteURL); }