private static void FaultingClose(object state)
        {
            Tuple <MessagingFactory, MessagingFactory, SendAvailabilityMessagePump> tuple = (Tuple <MessagingFactory, MessagingFactory, SendAvailabilityMessagePump>)state;
            MessagingFactory            item1 = tuple.Item1;
            MessagingFactory            item2 = tuple.Item2;
            SendAvailabilityMessagePump item3 = tuple.Item3;

            if (item1.IsOpened)
            {
                Exception pairedMessagingFactoryException = new PairedMessagingFactoryException(SRClient.FaultingPairedMessagingFactory(item1.Address.ToString(), item2.Address.ToString()));
                item1.Fault(pairedMessagingFactoryException);
            }
            if (!item3.Closed)
            {
                item3.Close();
            }
        }
 private void HandleUnplannedShutdown(MessagingFactory factory1, MessagingFactory factory2)
 {
     if (!this.Closed && (factory1.IsFaulted || factory1.IsClosedOrClosing) && (factory2.IsClosedOrClosing || factory2.IsFaulted))
     {
         this.Close();
         return;
     }
     if (factory1.IsFaulted && factory2.IsOpened)
     {
         Exception pairedMessagingFactoryException = new PairedMessagingFactoryException(SRClient.FaultingPairedMessagingFactory(factory2.Address.ToString(), factory1.Address.ToString()));
         factory2.Fault(pairedMessagingFactoryException);
         return;
     }
     if (factory1.IsClosedOrClosing && factory2.IsOpened)
     {
         IOThreadTimer oThreadTimer = new IOThreadTimer(new Action <object>(SendAvailabilityMessagePump.FaultingClose), new Tuple <MessagingFactory, MessagingFactory, SendAvailabilityMessagePump>(factory2, factory1, this), false);
         if (Interlocked.CompareExchange <IOThreadTimer>(ref this.closeTimer, oThreadTimer, null) == null)
         {
             oThreadTimer.Set(SendAvailabilityMessagePump.DefaultCloseTimeout);
         }
     }
 }