Esempio n. 1
0
        // Token: 0x06000314 RID: 788 RVA: 0x000137EC File Offset: 0x000119EC
        private RfriStatus EndWrapper(string methodName, ICancelableAsyncResult asyncResult, Func <RfriDispatchTask, RfriStatus> endDelegate)
        {
            RfriStatus rfriStatus = RfriStatus.Success;

            RfriAsyncDispatch.ConditionalExceptionWrapper(ExTraceGlobals.ReferralTracer.IsTraceEnabled(TraceType.DebugTrace), delegate
            {
                DispatchTaskAsyncResult dispatchTaskAsyncResult = asyncResult as DispatchTaskAsyncResult;
                if (dispatchTaskAsyncResult != null)
                {
                    RfriDispatchTask rfriDispatchTask = (RfriDispatchTask)dispatchTaskAsyncResult.DispatchTask;
                    using (DisposeGuard disposeGuard = default(DisposeGuard))
                    {
                        disposeGuard.Add <RfriDispatchTask>(rfriDispatchTask);
                        rfriStatus = endDelegate(rfriDispatchTask);
                    }
                    ExTraceGlobals.ReferralTracer.TraceDebug <string, RfriStatus>(0, 0L, "{0} succeeded. RfriStatus={1}.", methodName, rfriStatus);
                    return;
                }
                FailureAsyncResult <RfriStatus> failureAsyncResult = asyncResult as FailureAsyncResult <RfriStatus>;
                if (failureAsyncResult != null)
                {
                    rfriStatus = failureAsyncResult.ErrorCode;
                    ExTraceGlobals.ReferralTracer.TraceDebug <string, RfriStatus, Exception>(0, 0L, "{0} failed. RfriStatus={1}. Exception={2}.", methodName, rfriStatus, failureAsyncResult.Exception);
                    return;
                }
                throw new InvalidOperationException(string.Format("Invalid IAsyncResult encountered; {0}", asyncResult));
            }, delegate(Exception exception)
            {
                ExTraceGlobals.ReferralTracer.TraceDebug <string, Exception>(0, 0L, "{0} failed. Exception={1}.", methodName, exception);
            });
            return(rfriStatus);
        }
Esempio n. 2
0
        // Token: 0x06000313 RID: 787 RVA: 0x0001366C File Offset: 0x0001186C
        private ICancelableAsyncResult BeginWrapper(string methodName, CancelableAsyncCallback asyncCallback, object asyncState, ClientBinding clientBinding, string legacyDn, Func <RfriContext, RfriDispatchTask> beginDelegate)
        {
            ICancelableAsyncResult asyncResult = null;

            RfriAsyncDispatch.ConditionalExceptionWrapper(ExTraceGlobals.ReferralTracer.IsTraceEnabled(TraceType.DebugTrace), delegate
            {
                if (ExTraceGlobals.ReferralTracer.IsTraceEnabled(TraceType.DebugTrace))
                {
                    using (ClientSecurityContext clientSecurityContext = clientBinding.GetClientSecurityContext())
                    {
                        ExTraceGlobals.ReferralTracer.TraceDebug(0, 0L, "{0} started. LegacyDn={1}. ClientAddress={2}. ServerAddress={3}. ProtocolSequence={4}. EndPoint={5}. IsEncrypted={6}. ClientSecurityContext={7}.", new object[]
                        {
                            methodName,
                            legacyDn,
                            clientBinding.ClientAddress,
                            clientBinding.ServerAddress,
                            clientBinding.ProtocolSequence,
                            clientBinding.ClientEndpoint,
                            clientBinding.IsEncrypted,
                            clientSecurityContext
                        });
                    }
                }
                FailureAsyncResult <RfriStatus> failureAsyncResult = null;
                this.CheckShuttingDown();
                try
                {
                    using (DisposeGuard disposeGuard = default(DisposeGuard))
                    {
                        RfriContext rfriContext = RfriAsyncDispatch.CreateRfriContext(clientBinding);
                        disposeGuard.Add <RfriContext>(rfriContext);
                        RfriDispatchTask rfriDispatchTask = beginDelegate(rfriContext);
                        disposeGuard.Add <RfriDispatchTask>(rfriDispatchTask);
                        asyncResult = rfriDispatchTask.AsyncResult;
                        this.SubmitTask(rfriDispatchTask);
                        disposeGuard.Success();
                    }
                }
                catch (FailRpcException ex)
                {
                    failureAsyncResult = new FailureAsyncResult <RfriStatus>((RfriStatus)ex.ErrorCode, IntPtr.Zero, ex, asyncCallback, asyncState);
                    asyncResult        = failureAsyncResult;
                }
                catch (RfriException ex2)
                {
                    failureAsyncResult = new FailureAsyncResult <RfriStatus>(ex2.Status, IntPtr.Zero, ex2, asyncCallback, asyncState);
                    asyncResult        = failureAsyncResult;
                }
                if (failureAsyncResult != null && !ThreadPool.QueueUserWorkItem(RfriAsyncDispatch.FailureWaitCallback, failureAsyncResult))
                {
                    failureAsyncResult.InvokeCallback();
                }
                ExTraceGlobals.ReferralTracer.TraceDebug <string>(0, 0L, "{0} succeeded.", methodName);
            }, delegate(Exception exception)
            {
                ExTraceGlobals.ReferralTracer.TraceDebug <string, Exception>(0, 0L, "{0} failed. Exception={1}.", methodName, exception);
            });
            return(asyncResult);
        }