RabbitMQ.Client.Impl.ConnectionBase.MainLoop C# (CSharp) Method

MainLoop() public method

public MainLoop ( ) : void
return void
        public void MainLoop()
        {
            try
            {
                bool shutdownCleanly = false;
                try
                {
                    while (m_running)
                    {
                        try {
                            MainLoopIteration();
                        } catch (SoftProtocolException spe) {
                            QuiesceChannel(spe);
                        }
                    }
                    shutdownCleanly = true;
                }
                catch (EndOfStreamException eose)
                {
                    // Possible heartbeat exception
                    HandleMainLoopException(new ShutdownEventArgs(
                                                              ShutdownInitiator.Library,
                                                              0,
                                                              "End of stream",
                                                              eose));
                }
                catch (HardProtocolException hpe)
                {
                    shutdownCleanly = HardProtocolExceptionHandler(hpe);
                }
                catch (SocketException se)
                {
                    // Possibly due to handshake timeout
                    HandleMainLoopException(new ShutdownEventArgs(ShutdownInitiator.Library,
                                                              0,
                                                              "Socket exception",
                                                              se));
                }
                catch (Exception ex)
                {
                    HandleMainLoopException(new ShutdownEventArgs(ShutdownInitiator.Library,
                                                              CommonFraming.Constants.InternalError,
                                                              "Unexpected Exception",
                                                              ex));
                }

                // If allowed for clean shutdown, run main loop until the
                // connection closes.
                if (shutdownCleanly)
                {
                    try
                    {
                        ClosingLoop();
                    #pragma warning disable 0168
                    } catch (SocketException se)
                    {
                        // means that socket was closed when frame handler
                        // attempted to use it. Since we are shutting down,
                        // ignore it.
                    }
                    #pragma warning restore 0168
                }

                FinishClose();
            }
            finally
            {
                m_appContinuation.Set();
            }
        }