private void ConnectClicked() { AllDataBases.Clear(); Analyse.OnCanExecuteChanged(); // connection check var masterDBConnString = ConnectionStringBuilder.MasterDBConnectionStringCreate(SqlConnectionSettingsViewModel); if (!_sqlExecutor.ConnectionIsValid(masterDBConnString)) { HelpText = INIT_TEXT; OnPropertyChanged("HelpText"); OnPropertyChanged("DataBasesForChart"); _mainView.Dialogs.Error(@"Can't connect to server. Check connection settings, and make sure you have rights to connect that server."); return; } // databases info load ThreadPool.QueueUserWorkItem(delegate { foreach (string dbName in _sqlExecutor.LoadDatabaseList(masterDBConnString)) { var dbInfo = _dbInfoBuilder.Create(ConnectionStringBuilder.ConnectionStringCreate(SqlConnectionSettingsViewModel, dbName), dbName); Dispatcher.Invoke(new Action(() => AllDataBases.Add(new DBInfoListItem(dbInfo, this)))); } Dispatcher.Invoke(new Action(CheckBiggestDBs)); HelpText = AFTER_INIT_TEXT; OnPropertyChanged("HelpText"); RefreshChartBinding(); Dispatcher.Invoke(new Action(() => Analyse.OnCanExecuteChanged())); }); }