ConnectAsync() public abstract method

Returns true if connect is pending, the callback is invoked upon completion. Returns false if connect is completed synchronously, the callback is not invoked.
public abstract ConnectAsync ( System.TimeSpan timeout, TransportAsyncCallbackArgs callbackArgs ) : bool
timeout System.TimeSpan
callbackArgs TransportAsyncCallbackArgs
return bool
        public override bool ConnectAsync(TimeSpan timeout, TransportAsyncCallbackArgs callbackArgs)
        {
            AmqpTrace.Provider.AmqpLogOperationInformational(this, TraceOperation.Connect, this.transportSettings);
            TransportInitiator         innerInitiator = this.transportSettings.CreateInitiator();
            TransportAsyncCallbackArgs args           = new TransportAsyncCallbackArgs();

            args.CompletedCallback = this.OnConnectComplete;
            args.UserToken         = callbackArgs;
            callbackArgs.CompletedSynchronously = false;
            this.timeoutHelper = new TimeoutHelper(timeout);
            innerInitiator.ConnectAsync(timeout, args);
            return(true);
        }
Beispiel #2
0
        public override bool ConnectAsync(TimeSpan timeout, TransportAsyncCallbackArgs callbackArgs)
        {
            AmqpTrace.Provider.AmqpLogOperationInformational(this, TraceOperation.Connect, this.transportSettings);
            TransportInitiator         innerInitiator = this.transportSettings.CreateInitiator();
            TransportAsyncCallbackArgs args           = new TransportAsyncCallbackArgs();

            args.CompletedCallback = this.OnConnectComplete;
            args.UserToken         = callbackArgs;
            callbackArgs.CompletedSynchronously = false;
            this.timeoutHelper = new TimeoutHelper(timeout);
            if (innerInitiator.ConnectAsync(timeout, args))
            {
                return(true);
            }

            int currentThread = CurrentThreadId;

            Interlocked.Exchange(ref this.completingThread, currentThread);
            this.OnConnectComplete(args);
            return(Interlocked.Exchange(ref this.completingThread, -1) != 0);
        }
Beispiel #3
0
        /// <summary>
        /// Connects to the remote peer.
        /// </summary>
        /// <param name="timeout">The operation timeout.</param>
        /// <param name="callbackArgs">The callback arguments.</param>
        /// <returns>true if the operation is pending, false otherwise.</returns>
        public override bool ConnectAsync(TimeSpan timeout, TransportAsyncCallbackArgs callbackArgs)
        {
            this.callbackArgs  = callbackArgs;
            this.timeoutHelper = new TimeoutHelper(timeout);
            TransportInitiator innerInitiator = this.transportSettings.InnerTransportSettings.CreateInitiator();

            TransportAsyncCallbackArgs innerArgs = new TransportAsyncCallbackArgs();

            innerArgs.CompletedCallback = OnInnerTransportConnected;
            innerArgs.UserToken         = this;
            if (innerInitiator.ConnectAsync(timeout, innerArgs))
            {
                // pending
                return(true);
            }
            else
            {
                this.HandleInnerTransportConnected(innerArgs);
                return(!this.callbackArgs.CompletedSynchronously);
            }
        }