private void HandleConnectionResult(bool connected) { if (this.InvokeRequired) { this.Invoke(new MethodInvoker(() => HandleConnectionResult(connected))); } else { this.Cursor = Cursors.Default; _loadingControl.SendToBack(); _loadingControl.Visible = false; if (connected) { this.Hide(); _mainForm = new MainForm(); _mainForm.FormClosed += mainForm_FormClosed; _mainForm.ShowDialog(); } else { MessageBox.Show("Can't connect to Windows Service. Verify that it's running.", "Cannot connect", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }