Beispiel #1
0
        private WebsiteDataModel DownlaodWebSite(string websiteURL)
        {
            WebsiteDataModel output = new WebsiteDataModel();
            WebClient        client = new WebClient();

            output.WebsiteUrl  = websiteURL;
            output.WebsiteData = client.DownloadString(websiteURL);
            return(output);
        }
Beispiel #2
0
        private async Task <WebsiteDataModel> DownlaodWebSiteAsync(string websiteURL)
        {
            WebsiteDataModel output = new WebsiteDataModel();
            WebClient        client = new WebClient();

            output.WebsiteUrl  = websiteURL;
            output.WebsiteData = await client.DownloadStringTaskAsync(websiteURL);

            return(output);
        }
Beispiel #3
0
        private void RundownloadSync()
        {
            List <String> websites = PrepData();

            foreach (string site in websites)
            {
                WebsiteDataModel results = DownlaodWebSite(site);
                ReportWebsiteInfo(results);
            }
        }
Beispiel #4
0
        private async Task RundownloadASync()
        {
            List <String> websites = PrepData();

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

                ReportWebsiteInfo(results);
            }
        }
Beispiel #5
0
 private void ReportWebsiteInfo(WebsiteDataModel data)
 {
     txt1.Text += $"{data.WebsiteUrl}  downloaded: {data.WebsiteData.Length} characters long. {Environment.NewLine}";
 }