internal void Stop() { _listening = false; ConsoleConnection[] clients; lock (_connections) { clients = _connections.Values.ToArray(); } if (_listeningThread != null && _listeningThread.ThreadState == ThreadState.Running) { _listeningThread.Abort(); } foreach (var client in clients) { client.Dispose(); } if (string.IsNullOrEmpty(_csPortForwardIp)) { return; } try { Logger.Log("Attempting to remove port forwarding for Logger..."); var result = CrestronEthernetHelper.RemovePortForwarding((ushort)Port, (ushort)Port, _csPortForwardIp, CrestronEthernetHelper.ePortMapTransport.TCP); if (result == CrestronEthernetHelper.PortForwardingUserPatRetCodes.NoErr) { Logger.Log("Port forwarding removed ok!"); return; } Logger.Warn($"Could not remove port forwarding for Logger, result = {result}"); _csPortForwardIp = null; } catch (Exception e) { Logger.Error(e); } }