예제 #1
0
        private async void MainForm_Load(object sender, EventArgs e)
        {
            ///Thread thread = new Thread(() =>
            ///{
            ///    ProductApiService service = new ProductApiService();
            ///    var list = service.GetProducts();
            ///    foreach (var p in list)
            ///    {
            ///        object[] row = { p.Id, p.Name, p.Price };
            ///        dgvProducts.Rows.Add(row);
            ///    }
            ///    lblTredInfo.Text = "Завершено успішно";
            ///});
            ///thread.Start();
            ///
            Debug.WriteLine("-----Main thread----- {0}", Thread.CurrentThread.ManagedThreadId);
            IProductApiService service = new IProductApiService();
            var list = await service.GetProductsAsync();

            Debug.WriteLine("-----Main thread----- {0}", Thread.CurrentThread.ManagedThreadId);
            foreach (var p in list)
            {
                object[] row = { p.Id, p.Name, p.Price };
                dgvProducts.Rows.Add(row);
            }
            lblTredInfo.Text = "Завершено успішно";
        }