public bool StartConnection() { bool bConResult = false; _isConnected = false; /*if (_session != null) * if (_session.TerminalConnection != null) * _isConnected = _session.TerminalConnection.IsClosed; */ if (_Console == null) { _Console = new ConsoleMain(); } //ISynchronizedConnector synchCon = _Console.CreateSynchronizedConnector(null); if (ssh != null) { _connector = _Console.AsyncSSHConnect(this /* synchCon.InterruptableConnectorClient */, ssh); } else { _connector = _Console.AsyncTelnetConnect(this /* synchCon.InterruptableConnectorClient */, tcp); } if (_connector == null) { _isRunning = false; return(bConResult); } //_result = synchCon.WaitConnection(_connector, _timeout * 1000); while ((!_timedOut) && (!_isConnected)) { Thread.Sleep(100); } _result = ((InterruptableConnector)_connector).Result; if (_result == null) { _connector = null; _isRunning = false; return(bConResult); } try { _session = new TerminalSession(((InterruptableConnector)_connector).Result, _terminalSettings, _terminalOptions); _session._parent = this; //SessionHost host = new SessionHost(this, session); _session.InternalStart(); // => _output.Connection.Socket.RepeatAsyncRead(_terminal); bConResult = true; } catch (Exception ex) { bConResult = false; if (_debug > 0) { Console.WriteLine(ex.Message); } } return(bConResult); }