Example #1
0
        private void getCategoryList()
        {
            var t = new Task(() => { });

            t.Start();
            t.ContinueWith(task => {
                Connector databaseConnectCategory = new MYSQLDatabaseConnection();

                if (databaseConnectCategory.establish() == true)
                {
                    List <DatabaseColumn> CategoryList = databaseConnectCategory.GetAllCategoryNameWithId();


                    foreach (DatabaseColumn databseColumn in CategoryList)
                    {
                        cmbCategoryName.Items.Add(databseColumn.category_name);//add company name into combo box
                        TempCategoryList.Add(new DatabaseColumn()
                        {
                            category_name = databseColumn.category_name,
                            category_id   = databseColumn.category_id,
                        }
                                             );
                    }
                }
                else
                {
                    MessageBox.Show("connection error");
                }
            }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
        }