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