public async Task <ActionResult> PWGtimeOut(CancellationToken cancellationToken)
        {
            ViewBag.SyncType = "Asynchronous with CancellationToken";

            var widgetService = new WidgetService();
            var prodService   = new ProductService();
            var gizmoService  = new GizmoService();

            var widgetTask = widgetService.GetWidgetsAsync(cancellationToken);
            var prodTask   = prodService.GetProductsAsync(cancellationToken);
            var gizmoTask  = gizmoService.GetGizmosAsync(cancellationToken);

            await Task.WhenAll(widgetTask, prodTask, gizmoTask);

            var pwgVM = new ProdGizWidgetVM(
                widgetTask.Result,
                prodTask.Result,
                gizmoTask.Result
                );

            ViewBag.numGizmos   = pwgVM.gizmoList.Count();
            ViewBag.numWidgets  = pwgVM.widgetList.Count();
            ViewBag.numProducts = pwgVM.prodList.Count();

            return(View("PWG", pwgVM));
        }
Ejemplo n.º 2
0
        private async Task GetPWGsrvAsync()
        {
            var widgetService = new WidgetService();
            var prodService   = new ProductService();
            var gizmoService  = new GizmoService();

            var widgetTask = widgetService.GetWidgetsAsync();
            var prodTask   = prodService.GetProductsAsync();
            var gizmoTask  = gizmoService.GetGizmosAsync();

            await Task.WhenAll(widgetTask, prodTask, gizmoTask);

            var pwgVM = new ProdGizWidgetVM(
                widgetTask.Result,
                prodTask.Result,
                gizmoTask.Result
                );

            WidgetGridView.DataSource = pwgVM.widgetList;
            WidgetGridView.DataBind();
            ProductGridView.DataSource = pwgVM.prodList;
            ProductGridView.DataBind();
            GizmoGridView.DataSource = pwgVM.gizmoList;
            GizmoGridView.DataBind();
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            var widgetService = new WidgetService();
            var prodService   = new ProductService();
            var gizmoService  = new GizmoService();

            var pwgVM = new ProdGizWidgetVM(
                widgetService.GetWidgets(),
                prodService.GetProducts(),
                gizmoService.GetGizmos()
                );

            WidgetGridView.DataSource = pwgVM.widgetList;
            WidgetGridView.DataBind();
            ProductGridView.DataSource = pwgVM.prodList;
            ProductGridView.DataBind();
            GizmoGridView.DataSource = pwgVM.gizmoList;
            GizmoGridView.DataBind();

            stopWatch.Stop();
            ElapsedTimeLabel.Text = String.Format("Elapsed time: {0}",
                                                  stopWatch.Elapsed.Milliseconds / 1000.0);
        }
Ejemplo n.º 4
0
        //========= Combination
        public ActionResult PWG()
        {
            ViewBag.SyncOrAsync = Synchronous;

            var widgets  = _widgetService.GetWidgets();
            var products = _productService.GetProducts();
            var gizmos   = _gizmoService.GetGizmos();

            var model = new ProdGizWidgetVM(widgets, products, gizmos);

            return(View(model));
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> PWGAsync()
        {
            ViewBag.SyncOrAsync = Asynchronous;

            Task <List <Widget> >  widgetTask  = _widgetService.GetWidgetsAsync();
            Task <List <Product> > productTask = _productService.GetProductsAsync();
            Task <List <Gizmo> >   gizmoTask   = _gizmoService.GetGizmosAsync();

            await Task.WhenAll(widgetTask, productTask, gizmoTask);

            var model = new ProdGizWidgetVM(widgetTask.Result, productTask.Result, gizmoTask.Result);

            return(View("PWG", model));
        }
Ejemplo n.º 6
0
        public ActionResult PWG()
        {
            ViewBag.SyncType = "Synchronous";
            var widgetService = new WidgetService();
            var prodService   = new ProductService();
            var gizmoService  = new GizmoService();

            var pwgVM = new ProdGizWidgetVM(
                widgetService.GetWidgets(),
                prodService.GetProducts(),
                gizmoService.GetGizmos()
                );

            return(View("PWG", pwgVM));
        }
Ejemplo n.º 7
0
        public async Task <ActionResult> PWGasync()
        {
            ViewBag.SyncType = "Asynchronous";
            var widgetService = new WidgetService();
            var prodService   = new ProductService();
            var gizmoService  = new GizmoService();

            var widgetTask = widgetService.GetWidgetsAsync();
            var prodTask   = prodService.GetProductsAsync();
            var gizmoTask  = gizmoService.GetGizmosAsync();

            await Task.WhenAll(widgetTask, prodTask, gizmoTask);

            var pwgVM = new ProdGizWidgetVM(
                widgetTask.Result,
                prodTask.Result,
                gizmoTask.Result
                );

            return(View("PWG", pwgVM));
        }