private void RunDownloadParallelSync(IProgress <ProgresReportModel> progress, CancellationToken ct)
        {
            List <string>           webSites = PrepData();
            ProgresReportModel      report   = new ProgresReportModel();
            List <WebsiteDataModel> output   = new List <WebsiteDataModel>();

            Parallel.ForEach <string>(webSites, (site) =>
            {
                WebsiteDataModel results = DownloadWebsite(site);
                output.Add(results);
                ct.ThrowIfCancellationRequested();

                report.SitesDownloaded    = output;
                report.PercentageComplete = (output.Count * 100) / webSites.Count;

                progress.Report(report);
            });
            PrintResults(output);
        }
        private async Task RunDownloadAsync(IProgress <ProgresReportModel> progress, CancellationToken ct)
        {
            List <string>           webSites = PrepData();
            ProgresReportModel      report   = new ProgresReportModel();
            List <WebsiteDataModel> output   = new List <WebsiteDataModel>();

            foreach (string site in webSites)
            {
                WebsiteDataModel results = await Task.Run(() => DownloadWebsite(site));

                output.Add(results);

                ct.ThrowIfCancellationRequested();

                report.SitesDownloaded    = output;
                report.PercentageComplete = (output.Count * 100) / webSites.Count;

                progress.Report(report);
            }
        }
 private void ReportProgress(object sender, ProgresReportModel e)
 {
     progressBar.Value = e.PercentageComplete;
     PrintResults(e.SitesDownloaded);
 }