Meebey.SmartIrc4net.IrcConnection.IdleWorkerThread._Worker C# (CSharp) Method

_Worker() private method

private _Worker ( ) : void
return void
            private void _Worker()
            {
                #if LOG4NET
                Logger.Socket.Debug("IdleWorkerThread started");
                #endif
                try {
                   while (_Connection.IsConnected ) {
                       if (_Connection.IsRegistered) {
                           DateTime now = DateTime.UtcNow;
                           int last_ping_sent = (int)(now - _Connection._LastPingSent).TotalSeconds;
                           int last_pong_rcvd = (int)(now - _Connection._LastPongReceived).TotalSeconds;
                           // determines if the response time is ok
                           if (last_ping_sent < _Connection._PingTimeout) {
                               // determines if it need to send another ping yet
                               if (last_pong_rcvd > _Connection._PingInterval) {
                                   _Connection.WriteLine(Rfc2812.Ping(_Connection.Address), Priority.Critical);
                                   _Connection._LastPingSent = now;
                                   _Connection._LastPongReceived = now;
                               } // else connection is fine, just continue
                           } else {
                #if LOG4NET
                               Logger.Socket.Warn("ping timeout, connection lost");
                #endif
                               _Connection.IsConnectionError = true;
                               break;
                           }
                       }
                       Thread.Sleep(_Connection._IdleWorkerInterval);
                   }
                } catch (ThreadAbortException) {
                    Thread.ResetAbort();
                #if LOG4NET
                    Logger.Socket.Debug("IdleWorkerThread aborted");
                #endif
                }
            }
IrcConnection.IdleWorkerThread