Ejemplo n.º 1
0
        private WebsiteDataModel DownloadWebsite(string websiteURL)
        {
            WebsiteDataModel output = new WebsiteDataModel();
            WebClient        client = new WebClient();

            output.WebsiteURL  = websiteURL;
            output.WebsiteData = client.DownloadString(websiteURL);

            return(output);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        private void RunDownloadSync()
        {
            List <string> websites = PrepData();

            foreach (string site in websites)
            {
                WebsiteDataModel result = DownloadWebsite(site);
                ReportWebsiteInfo(result);
            }
        }
Ejemplo n.º 4
0
        private async Task RunDownloadAsync()
        {
            List <string> websites = PrepData();

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

                ReportWebsiteInfo(result);
            }
        }
Ejemplo n.º 5
0
 private void ReportWebsiteInfo(WebsiteDataModel data)
 {
     resultsWindow.Text += $"{ data.WebsiteURL } downloaded { data.WebsiteData.Length } characters long.{ Environment.NewLine }";
 }