Ejemplo n.º 1
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.º 2
0
        public async Task <ActionResult> WidgetsAsync()
        {
            ViewBag.SyncOrAsync = "Asynchronous";
            var widgetService = new WidgetService();

            return(View("Widgets", await widgetService.GetWidgetsAsync()));
        }
        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.º 4
0
        private async Task GetWidgetSrvAsync()
        {
            var widgetService = new WidgetService();
            var widgetList    = await widgetService.GetWidgetsAsync();

            WidgetGridView.DataSource = widgetList;
            WidgetGridView.DataBind();

            stopWatch.Stop();
            ElapsedTimeLabel.Text = String.Format("Elapsed time: {0}", stopWatch.Elapsed.Milliseconds / 1000.0);
        }
        public async Task <ActionResult> WidgetsAsync()
        {
            System.Diagnostics.Debug.WriteLine("Entering WidgetsAsync. Context: " + SynchronizationContext.Current.GetHashCode());
            ViewBag.SyncOrAsync = "Asynchronous";
            var widgetService = new WidgetService();
            var widgets       = await widgetService.GetWidgetsAsync();

            ViewBag.numWidgets = widgets.Count();
            System.Diagnostics.Debug.WriteLine("Leaving WidgetsAsync");

            return(View("Widgets", widgets));
        }
Ejemplo n.º 6
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));
        }