Exemplo n.º 1
0
        public void init()
        {
            this.m_delegate = new Connection(m_factory, false, m_factory.CreateFrameHandler());

            var self = this;
            ConnectionShutdownEventHandler recoveryListener = (_, args) =>
            {
                lock (self)
                {
                    if (ShouldTriggerConnectionRecovery(args))
                    {
                        try
                        {
                            self.BeginAutomaticRecovery();
                        } catch (Exception e)
                        {
                            // TODO: logging
                            Console.WriteLine("BeginAutomaticRecovery() failed: {0}", e);
                        }
                    }
                }
            };

            lock (this.m_eventLock)
            {
                this.ConnectionShutdown += recoveryListener;
                if (!this.m_recordedShutdownEventHandlers.Contains(recoveryListener))
                {
                    this.m_recordedShutdownEventHandlers.Add(recoveryListener);
                }
            }
        }
Exemplo n.º 2
0
        ///<summary>Broadcasts notification of the final shutdown of the connection.</summary>
        public void OnShutdown()
        {
            ConnectionShutdownEventHandler handler;
            ShutdownEventArgs reason;

            lock (m_eventLock)
            {
                handler = m_connectionShutdown;
                reason  = m_closeReason;
                m_connectionShutdown = null;
            }
            if (handler != null)
            {
                foreach (ConnectionShutdownEventHandler h in handler.GetInvocationList())
                {
                    try {
                        h(this, reason);
                    } catch (Exception e) {
                        CallbackExceptionEventArgs args = new CallbackExceptionEventArgs(e);
                        args.Detail["context"] = "OnShutdown";
                        OnCallbackException(args);
                    }
                }
            }
            AppDomain.CurrentDomain.DomainUnload -= HandleDomainUnload;
        }
Exemplo n.º 3
0
        ///<summary>Broadcasts notification of the final shutdown of the connection.</summary>
        public void OnShutdown()
        {
            ConnectionShutdownEventHandler shutdownHandler;
            ShutdownEventArgs reason;

            lock (m_eventLock)
            {
                shutdownHandler      = m_connectionShutdown;
                reason               = m_closeReason;
                m_connectionShutdown = null;
            }

            RaiseEvent(shutdownHandler, reason);
            AppDomain.CurrentDomain.DomainUnload -= HandleDomainUnload;

            ConnectionShutdownEventHandler afterShutdownHandler;

            lock (m_eventLock)
            {
                afterShutdownHandler = m_afterConnectionShutdown;
                reason = m_closeReason;
                m_afterConnectionShutdown = null;
            }
            RaiseEvent(afterShutdownHandler, reason);
        }
 ///<summary>Broadcasts notification of the final shutdown of the connection.</summary>
 public void OnShutdown()
 {
     ConnectionShutdownEventHandler handler;
     ShutdownEventArgs reason;
     lock (m_eventLock)
     {
         handler = m_connectionShutdown;
         reason = m_closeReason;
         m_connectionShutdown = null;
     }
     if (handler != null)
     {
         foreach (ConnectionShutdownEventHandler h in handler.GetInvocationList()) {
             try {
                 h(this, reason);
             } catch (Exception e) {
                 CallbackExceptionEventArgs args = new CallbackExceptionEventArgs(e);
                 args.Detail["context"] = "OnShutdown";
                 OnCallbackException(args);
             }
         }
     }
     AppDomain.CurrentDomain.DomainUnload -= HandleDomainUnload;
 }