Website_VM downloadwebsite(string url) { WebClient webClient = new WebClient(); var obj = new Website_VM { WebSiteUrl = url, WebSiteData = webClient.DownloadString(url) }; return(obj); }
void RunDownloadSync() { List <string> Websites = PreData(); foreach (var item in Websites) { Website_VM result = downloadwebsite(item); ReportWebsiteInfo(result); } }
async Task RunDownload_Async() { List <string> Websites = PreData(); foreach (var item in Websites) { Website_VM result = await Task.Run(() => downloadwebsite(item)); ReportWebsiteInfo(result); } }
void ReportWebsiteInfo(Website_VM data) { Console.WriteLine($"{data.WebSiteUrl} , Downloaded: {data.WebSiteData.Length} , Characters Long. {Environment.NewLine}"); }