Microsoft.Azure.Amqp.Transport.AmqpTransportInitiator.Complete C# (CSharp) Method

Complete() private method

private Complete ( TransportAsyncCallbackArgs args ) : void
args TransportAsyncCallbackArgs
return void
        void Complete(TransportAsyncCallbackArgs args)
        {
            if (args.Exception != null && args.Transport != null)
            {
                args.Transport.SafeClose(args.Exception);
                args.Transport = null;
            }

            TransportAsyncCallbackArgs innerArgs = (TransportAsyncCallbackArgs)args.UserToken;
            innerArgs.Transport = args.Transport;
            innerArgs.Exception = args.Exception;

            int currentThread = CurrentThreadId;
            innerArgs.CompletedSynchronously = Interlocked.Add(ref this.completingThread, -currentThread) == 0;
            if (!innerArgs.CompletedSynchronously)
            {
                innerArgs.CompletedCallback(innerArgs);
            }
        }