// ClosedCallback is a delegate to determine if caller has closed. If so, we bail out of open operation public NeighborOpenAsyncResult(PeerNeighbor neighbor, PeerNodeAddress remoteAddress, Binding binding, PeerService service, ClosedCallback closedCallback, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state) { this.neighbor = neighbor; IAsyncResult result = null; try { result = neighbor.BeginOpen(remoteAddress, binding, service, closedCallback, timeout, Fx.ThunkCallback(new AsyncCallback(OnOpen)), null); if (result.CompletedSynchronously) { neighbor.EndOpen(result); } } catch (Exception e) { if (Fx.IsFatal(e)) throw; neighbor.TraceEventHelper(TraceEventType.Warning, TraceCode.PeerNeighborOpenFailed, SR.GetString(SR.TraceCodePeerNeighborOpenFailed)); throw; } // Indicate [....] completion to the caller if (result.CompletedSynchronously) base.Complete(true); }