public void StopDatabaseListRefresh() { _loader.Stop(); Cursor = Cursors.Arrow; _databaseComboBox.Enabled = true; _usernameTextBox.Enabled = true; _passwordTextBox.Enabled = true; _loginButton.Enabled = true; _usernameTextBox.Focus(); }
private void InitDatabaseList() { var backgroundWorker = new BackgroundWorker(); var databases = new List <SqlDatabaseSettings>(); var loaderControl = new LoaderControl(); backgroundWorker.DoWork += (sender, args) => { var databaseService = ServicesProvider.GetInstance().GetDatabaseServices(); databases = databaseService.GetOpenCbsDatabases(); }; backgroundWorker.RunWorkerCompleted += (sender, args) => { loaderControl.Stop(); if (args.Error != null) { MessageBox.Show(args.Error.Message); return; } Enable(); var index = -1; var i = 0; foreach (var database in databases) { databaseCombobox.Items.Add(database.Name); if (database.Name == TechnicalSettings.DatabaseName) { index = i; } i++; } databaseCombobox.SelectedIndex = index; usernameTextbox.Focus(); databaseCombobox.SelectedIndexChanged += (sender2, args2) => ChangeDefaultDatabaseAndRestart(); }; Controls.Add(loaderControl); loaderControl.AttachTo(databaseCombobox); loaderControl.Start(); Disable(); backgroundWorker.RunWorkerAsync(); }