//*********************************************************************// // Form closing. If the connection thread was ever created then kill // // it off. // //*********************************************************************// private void FormServer_FormClosing(object sender, FormClosingEventArgs e) { if (threadConnection != null) { threadConnection.StopThread(); } }
/// <summary> /// Kills off any connection thread that was ever created /// and checks if any clients are still connected before closing server /// </summary> private void FormServer_FormClosing(object sender, FormClosingEventArgs e) { if (connectedClients.Count > 0) { MessageBox.Show("Cannot exit while there are clients connected, please disconnect them first.", "Clients are connected", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // Cancel closing server form e.Cancel = true; } else { if (threadConnection != null) { threadConnection.StopThread(); } } }