Ejemplo n.º 1
0
 private static void ReportWebSiteInfo(WebsiteDataModel data)
 {
     if (data == null)
     {
         return;
     }
     Console.WriteLine($"{ data.WebsiteUrl, 25 } \tdownloaded: { data.WebsiteData.Length, 10 } characters long.");
 }
Ejemplo n.º 2
0
        private static void RunDownloadSync()
        {
            List <string> websites = PrepareData();

            foreach (var website in websites)
            {
                WebsiteDataModel results = DownloadWebsite(website);
                ReportWebSiteInfo(results);
            }
        }
Ejemplo n.º 3
0
        private static async Task <WebsiteDataModel> DownloadWebsiteAsync(string website)
        {
            WebsiteDataModel output = new WebsiteDataModel();
            WebClient        client = new WebClient();

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

            return(output);
        }
Ejemplo n.º 4
0
        private static WebsiteDataModel DownloadWebsite(string website)
        {
            WebsiteDataModel output = new WebsiteDataModel();
            WebClient        client = new WebClient();

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

            return(output);
        }
Ejemplo n.º 5
0
        private static async Task RunDownloadAsync()
        {
            List <string> websites = PrepareData();

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

                ReportWebSiteInfo(results);
            }
        }