private void InformationConnection(bool value) //проверка подключения к базе данных { try { Action action = () => { switch (value) { case (true): lbsstConnection.Text = RegistryData.DataSourceIP + "\\" + RegistryData.DataSourceServerName + " - " + RegistryData.InitialCatalog; //AuthorizationForm authorizationForm = new AuthorizationForm(); //authorizationForm.Show(this); break; case (false): lbsstConnection.Text = "Нет подключения к базе данных"; foreach (Form f in Application.OpenForms) { if (f.Name == "ConnectionForm") { return; } } ConnectionForm connectionForm = new ConnectionForm(); connectionForm.Show(this); break; } }; Invoke(action); } catch { threadCheckConnection.Abort(); } }
private void button1_Click(object sender, EventArgs e) { ConnectionForm connectionForm = new ConnectionForm(); connectionForm.Show(); }