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;
}