public ActionResult Index() { var beginTime = DateTime.Now; var htmlDownload = new HTMLDownload(); var page1 = htmlDownload.GetHTML(1); var page2 = htmlDownload.GetHTML(2); var page3 = htmlDownload.GetHTML(3); var htmlReturn = page1.Result; htmlReturn += page2.Result; htmlReturn += page3.Result; var duringTime = (DateTime.Now - beginTime).TotalMilliseconds; ViewBag.HtmlReturn = htmlReturn + $" Execute Time in: {duringTime}"; return(View()); }
public async Task <ActionResult> IndexAsynchronous() { var beginTime = DateTime.Now; var htmlDownload = new HTMLDownload(); var page1 = htmlDownload.GetHTML(1); var page2 = htmlDownload.GetHTML(2); var page3 = htmlDownload.GetHTML(3); await Task.WhenAll(page1, page2, page3); var htmlReturn = page1.Result; htmlReturn += page2.Result; htmlReturn += page3.Result; var duringTime = (DateTime.Now - beginTime).TotalMilliseconds; ViewBag.HtmlReturn = htmlReturn + $" Execute Time in: {duringTime}"; return(View("Index")); }