// Begin opening of a neighbor channel to 'to'. instanceContext is where the remote 
 // endpoint should send messages to (it will be a reference to PeerNeighborManager).
 public IAsyncResult BeginOpen(PeerNodeAddress remoteAddress, Binding binding,
     PeerService service, ClosedCallback closedCallback, TimeSpan timeout,
     AsyncCallback callback, object asyncState)
 {
     this.initiator = true;
     this.listenAddress = remoteAddress;
     OpenAsyncResult result = new OpenAsyncResult(this, remoteAddress, binding, service,
         closedCallback, timeout, callback, state);
     return result;
 }
        public IAsyncResult BeginOpen(TimeSpan timeout, AsyncCallback callback, object state)
        {
            if (timeout < TimeSpan.Zero)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                    new ArgumentOutOfRangeException("timeout", SR.GetString(SR.SFxTimeoutOutOfRange0)));

            lock (ThisLock)
            {
                ThrowIfDisposedOrImmutable();
                this.state = CommunicationState.Opening;
            }

            bool throwing = true;
            try
            {
                OnOpening();
                if (!this.onOpeningCalled)
                    throw TraceUtility.ThrowHelperError(this.CreateBaseClassMethodNotCalledException("OnOpening"), Guid.Empty, this);

                IAsyncResult result = new OpenAsyncResult(this, timeout, callback, state);
                throwing = false;
                return result;
            }
            finally
            {
                if (throwing)
                {
                    if (DiagnosticUtility.ShouldTraceWarning)
                    {
                        TraceUtility.TraceEvent(TraceEventType.Warning, TraceCode.CommunicationObjectOpenFailed, SR.GetString(SR.TraceCodeCommunicationObjectOpenFailed, this.GetCommunicationObjectType().ToString()), this);
                    }

                    Fault();
                }
            }
        }
 public IAsyncResult BeginOpen(TimeSpan timeout, AsyncCallback callback, object state)
 {
     IAsyncResult result2;
     if (timeout < TimeSpan.Zero)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("timeout", System.ServiceModel.SR.GetString("SFxTimeoutOutOfRange0")));
     }
     lock (this.ThisLock)
     {
         this.ThrowIfDisposedOrImmutable();
         this.state = CommunicationState.Opening;
     }
     bool flag = true;
     try
     {
         this.OnOpening();
         if (!this.onOpeningCalled)
         {
             throw TraceUtility.ThrowHelperError(this.CreateBaseClassMethodNotCalledException("OnOpening"), Guid.Empty, this);
         }
         IAsyncResult result = new OpenAsyncResult(this, timeout, callback, state);
         flag = false;
         result2 = result;
     }
     finally
     {
         if (flag)
         {
             if (DiagnosticUtility.ShouldTraceWarning)
             {
                 TraceUtility.TraceEvent(TraceEventType.Warning, 0x80005, System.ServiceModel.SR.GetString("TraceCodeCommunicationObjectOpenFailed", new object[] { this.GetCommunicationObjectType().ToString() }), this);
             }
             this.Fault();
         }
     }
     return result2;
 }