Beispiel #1
0
        /// <summary>
        /// Starts a connection (synchronously).
        /// </summary>
        public void Start()
        {
            lock (_startStopLock)
            {
                //signalling
                if (_isStarted)
                {
                    //already started
                    return;
                }
                _isStopping = false;
                _isStopped  = new ManualResetEvent(false);

                //Reset disconnect counter
                DisconnectCounter = 0;

                //On initial start ensure we have a fresh session (to avoid risk of invalid session).
                _sessionProvider.ExpireTokenNow();


                //Socket level connect
                ConnectSocket();

                //Start processing thread
                Thread thread = new Thread(new ThreadStart(Run));
                thread.Name = "ESAClient";
                thread.Start();

                //Start keep alive timer
                _keepAliveTimer = new Timer(KeepAliveCheck, null, Timeout, Timeout);

                ConnectAndAuthenticate();

                //got to here so we are started
                _isStarted = true;
            }
        }