Exemplo n.º 1
0
        private async Task LoadProductsAsync()
        {
            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "LoadProductsAsync():Start"
            });

            ProductProxyService.ProductServiceClient client   = new ProductProxyService.ProductServiceClient();
            IList <ProductProxyService.Product>      products = await client.GetProductsTaskAsync();

            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "LoadProductsAsync():End"
            });

            ProductGridView.DataSource = products.Take(10);
            ProductGridView.DataBind();

            ThreadGridView.DataSource = statistics;
            ThreadGridView.DataBind();

            TimeSpan ts = pageWatch.Elapsed;

            PageElapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                            ts.Hours, ts.Minutes, ts.Seconds,
                                            ts.Milliseconds / 10);
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Stopwatch loadWatch = new Stopwatch();
            //loadWatch.Start();


            pageWatch.Start();
            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "Page Load:Start"
            });

            LoadProducts();

            LoadSaleOrders();

            LoadPersons();



            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "Page Load:End"
            });

            ThreadGridView.DataSource = statistics;
            ThreadGridView.DataBind();

            TimeSpan ts = pageWatch.Elapsed;

            PageElapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                            ts.Hours, ts.Minutes, ts.Seconds,
                                            ts.Milliseconds / 10);
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Stopwatch loadWatch = new Stopwatch();

            loadWatch.Start();


            pageWatch.Start();
            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "Page Load:Start"
            });

            //RegisterAsyncTask(new PageAsyncTask(LoadProductsAsync));
            RegisterAsyncTask(new PageAsyncTask(async() => {
                statistics.Add(new Statistic {
                    ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "LoadProductsAsync():Start"
                });

                ProductProxyService.ProductServiceClient client = new ProductProxyService.ProductServiceClient();
                IList <ProductProxyService.Product> products    = await client.GetProductsTaskAsync();
                statistics.Add(new Statistic {
                    ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "LoadProductsAsync():End"
                });

                ProductGridView.DataSource = products.Take(10);
                ProductGridView.DataBind();

                ThreadGridView.DataSource = statistics;
                ThreadGridView.DataBind();

                TimeSpan ts1    = pageWatch.Elapsed;
                PageElapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                                ts1.Hours, ts1.Minutes, ts1.Seconds,
                                                ts1.Milliseconds / 10);
            }));


            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "Page Load::End"
            });


            TimeSpan ts = loadWatch.Elapsed;

            LoadElapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                            ts.Hours, ts.Minutes, ts.Seconds,
                                            ts.Milliseconds / 10);
        }
Exemplo n.º 4
0
        private void LoadPersons()
        {
            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "LoadPersons():Start"
            });
            PersonProxyService.PersonServiceClient client   = new PersonProxyService.PersonServiceClient();
            IList <PersonProxyService.Person>      products = client.GetPersons();

            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "LoadPersons():End"
            });
            PersonGridView.DataSource = products.Take(10);
            PersonGridView.DataBind();

            ThreadGridView.DataSource = statistics;
            ThreadGridView.DataBind();
        }
        private async Task LoadAsync()
        {
            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "LoadAsync():Start"
            });
            ProductProxyService.ProductServiceClient     client          = new ProductProxyService.ProductServiceClient();
            SaleOrderProxyService.SaleOrderServiceClient saleOrderClient = new SaleOrderProxyService.SaleOrderServiceClient();
            PersonProxyService.PersonServiceClient       personClient    = new PersonProxyService.PersonServiceClient();


            var productsTask   = client.GetProductsTaskAsync();
            var saleOrdersTask = saleOrderClient.GetSaleOrdersTaskAsync();
            var personTask     = personClient.GetPersonsTaskAsync();

            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "LoadAsync():Before WhenAll()"
            });

            await Task.WhenAll(productsTask, saleOrdersTask, personTask);

            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "LoadAsync():Tasks all done."
            });

            LoadProducts(productsTask.Result);
            LoadSaleOrders(saleOrdersTask.Result);
            LoadPersons(personTask.Result);

            statistics.Add(new Statistic {
                ThreadId = Thread.CurrentThread.ManagedThreadId, Message = "LoadAsync():Exit"
            });
            ThreadGridView.DataSource = statistics;
            ThreadGridView.DataBind();

            TimeSpan ts = pageWatch.Elapsed;

            PageElapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                            ts.Hours, ts.Minutes, ts.Seconds,
                                            ts.Milliseconds / 10);
        }