Exemple #1
0
        public ActionResult Sincrono()
        {
            ViewBag.Inicio = DateTime.Now;
            TesteAsync t = new TesteAsync();
            var        x = t.Processar1();
            var        y = t.Processar2();
            var        z = t.Processar3();

            ViewBag.Fim = DateTime.Now;
            return(View("Index"));
        }
Exemple #2
0
        public async Task <ActionResult> Assincrono()
        {
            ViewBag.Inicio = DateTime.Now;
            TesteAsync t = new TesteAsync();
            var        x = t.ProcessarAsync1();
            var        y = t.ProcessarAsync2();
            var        z = t.ProcessarAsync3();

            await Task.WhenAll(x, y, z);

            var a = x.Result;
            var b = y.Result;
            var c = z.Result;

            ViewBag.Fim = DateTime.Now;
            return(View("Index"));
        }