public async Task<ActionResult> Acao(int id = 2) { var cron = new Stopwatch(); cron.Start(); var svc = new TaskService.Service1Client(); var results = await Task.WhenAll(from e in Enumerable.Range(0, 5) select svc.GetDataAsync(id + e)); string transformedValue = string.Join(", ", results); var time = Convert.ToDouble(cron.ElapsedMilliseconds) / 1000; ViewBag.Time = time; return View("RetornoServico", (object)transformedValue); }
public ActionResult Acao(int id = 3) { var cron = new Stopwatch(); cron.Start(); var svc = new TaskService.Service1Client(); string transformedValue = ""; for (int i = 0; i < 5; i++) { transformedValue += svc.GetData(id) + ", "; id++; } var time = Convert.ToDouble(cron.ElapsedMilliseconds) / 1000; ViewBag.Time = time; return View("RetornoServico", (object)transformedValue); }