public void Stop() { if (_state != PortListenerState.Stopped) { return; } if (_state != PortListenerState.Running) { throw new InvalidOperationException(string.Format("The listener must have the state 'Running' when calling Stop. State {0} is not valid.", _state)); } _state = PortListenerState.Stopped; _tcpListener.Stop(); foreach (var tcpActor in _tcpActors) { tcpActor.Stop(); } _listenerTask.Wait(); _listenerTask.Dispose(); if (_tcpActors.Count > 0) { var exp = new InvalidOperationException("There are still tcpActors that have not yet been stoped and removed."); exp.Data.Add("TcpActors.Count", _tcpActors.Count); throw exp; } }
public void Start() { if (_state != PortListenerState.NotStarted) { throw new InvalidOperationException(string.Format("The listener must have the state 'NotStarted' when calling Start. State {0} is not valid.", _state)); } _state = PortListenerState.Running; _tcpListener.Start(PublicPortRequested); _listenerTask.Start(); }
public void Stop() { if (_state != PortListenerState.Stopped) return; if (_state != PortListenerState.Running) throw new InvalidOperationException(string.Format("The listener must have the state 'Running' when calling Stop. State {0} is not valid.", _state)); _state = PortListenerState.Stopped; _tcpListener.Stop(); foreach (var tcpActor in _tcpActors) tcpActor.Stop(); _listenerTask.Wait(); _listenerTask.Dispose(); if (_tcpActors.Count > 0) { var exp = new InvalidOperationException("There are still tcpActors that have not yet been stoped and removed."); exp.Data.Add("TcpActors.Count", _tcpActors.Count); throw exp; } }
public void Start() { if (_state != PortListenerState.NotStarted) throw new InvalidOperationException(string.Format("The listener must have the state 'NotStarted' when calling Start. State {0} is not valid.",_state)); _state = PortListenerState.Running; _tcpListener.Start(PublicPortRequested); _listenerTask.Start(); }