protected override void OnClosing(CancelEventArgs e) { base.OnClosing(e); string message = "Server stop on:" + myTcpServer.ServerIP + ":" + myTcpServer.ServerPort; myTcpServer.Logger.Log(message); this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => { txt.AppendText(message + "\r\n\r\n"); txt.ScrollToEnd(); })); myTcpServer.Stop(); }
/// <summary> /// Shuts down the server. /// </summary> public async Task ShutdownAsync() { // TODO check if server can be shut down async, otherwise remove async // shutdown both UDP and TCP server sockets if (_udpServer != null) { Logger.Debug("Shutting down UDP server..."); _udpServer.Stop(); Logger.Debug("UDP server shut down."); } if (_tcpServer != null) { Logger.Debug("Shutting down TCP server..."); _tcpServer.Stop(); Logger.Debug("TCP server shut down."); } }