private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (string.Equals((sender as Button).Name, @"CloseButton")) { // Do something proper to CloseButton. } else { tcpDiagnoseServer.closeAllConnections(); } if (notifyIcon != null) { notifyIcon.Dispose(); } }
private void FormDatabase_Closing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.ApplicationExitCall) { tcpDiagnoseClient.closeAllConnections(); if (backgroundWorker_CheckAliveState.IsBusy) { backgroundWorker_CheckAliveState.CancelAsync(); } closeApplication(); } else { // DO nothing } }