// 界面关闭时,关闭相应未断开的连接 private void ControlFrm_FormClosing(object sender, FormClosingEventArgs e) { if (tcpClient.Connected) { devMonitor.StopMonitor(); // 关闭当前连接 tcpClient.Close(); } }