Exemple #1
0
        public ActionResult IndexAsync()
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();
            TimeConsumingModel model = new TimeConsumingModel();
            var contentTask          = model.HeavyContent1Async();
            var countTask            = model.HeavyContent2Async();
            var nameTask             = model.HeavyContent3Async();

            var content = contentTask;
            var count   = countTask;
            var name    = nameTask;

            watch.Stop();
            ViewBag.WatchMilliseconds = watch.ElapsedMilliseconds;
            ViewBag.Content           = content.ToString() + " - " + count + " - " + name;
            return(View("Index"));
        }
Exemple #2
0
        //[HttpGet]
        public async Task <ActionResult> IndexAsync()
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();
            TimeConsumingModel model = new TimeConsumingModel();

            //Lanzo las 3 tareas
            var contentTask = model.HeavyContent1Async();
            var countTask   = model.HeavyContent2Async();
            var nameTask    = model.HeavyContent3Async();

            //Espero que terminen las tres
            var content = await contentTask;
            var count   = await countTask;
            var name    = await nameTask;

            watch.Stop();
            ViewBag.WatchMilliseconds = watch.ElapsedMilliseconds;
            ViewBag.Content           = content.ToString() + " - " + count + " - " + name;
            return(View("Index"));
        }