예제 #1
0
        private WebsiteDataModel DownloadWebsite(string websiteURL)
        {
            var output = new WebsiteDataModel();
            var client = new WebClient();

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

            return(output);
        }
예제 #2
0
        private void RunDownLoadSync()
        {
            List <string> websites = Prepdata();

            foreach (var site in websites)
            {
                WebsiteDataModel result = DownloadWebsite(site);
                ReportWebsiteInfo(result);
            }
        }
예제 #3
0
        private async Task RunDownLoadASync()
        {
            List <string> websites = Prepdata();

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

                ReportWebsiteInfo(result);
            }
        }
예제 #4
0
 private void ReportWebsiteInfo(WebsiteDataModel website)
 {
     resultsWindow.Text += $"{website.WebsiteUrl} downloaded: {website.WebsiteData.Length} characters long.{Environment.NewLine}";
 }