public static CancelableAsyncCallback WrapCancellableCallbackWithUnhandledExceptionHandlerAndUpdatePoisonContext(CancelableAsyncCallback callback)
 {
     if (callback == null)
     {
         return(null);
     }
     return(delegate(ICancelableAsyncResult asyncResult)
     {
         RightsManagementAsyncResult asyncResultRM = null;
         if (asyncResult != null && asyncResult.AsyncState != null)
         {
             asyncResultRM = (asyncResult.AsyncState as RightsManagementAsyncResult);
         }
         try
         {
             if (asyncResultRM != null)
             {
                 asyncResultRM.InvokeSaveContextCallback();
             }
             callback(asyncResult);
         }
         catch (Exception exception)
         {
             ExWatson.SendReportAndCrashOnAnotherThread(exception, ReportOptions.None, delegate(Exception param0, int param1)
             {
                 if (asyncResultRM != null)
                 {
                     asyncResultRM.InvokeSaveContextCallback();
                 }
             }, null);
             throw;
         }
     });
 }
Beispiel #2
0
 private static AsyncCallback WrapCallbackWithUnhandledExceptionAndCrash(AsyncCallback callback)
 {
     if (callback == null)
     {
         return(null);
     }
     return(delegate(IAsyncResult asyncResult)
     {
         RightsManagementAsyncResult asyncResultRM = asyncResult as RightsManagementAsyncResult;
         try
         {
             if (asyncResultRM != null)
             {
                 asyncResultRM.InvokeSaveContextCallback();
             }
             callback(asyncResult);
         }
         catch (Exception exception)
         {
             Exception exception2;
             ExWatson.SendReportAndCrashOnAnotherThread(exception2, ReportOptions.None, delegate(Exception exception, int threadId)
             {
                 if (asyncResultRM != null)
                 {
                     asyncResultRM.InvokeSaveContextCallback();
                 }
             }, null);
             throw;
         }
     });
 }
            public bool Enqueue(RightsManagementAsyncResult asyncResult)
            {
                int count;

                lock (this.syncRoot)
                {
                    count = this.queue.Count;
                    this.queue.Enqueue(asyncResult);
                }
                ExTraceGlobals.RightsManagementTracer.TraceDebug <int>((long)this.GetHashCode(), "Number of elements in the queue : {0}", count + 1);
                return(count == 0);
            }
Beispiel #4
0
        internal void InvokeSaveContextCallback()
        {
            RightsManagementAsyncResult rightsManagementAsyncResult = base.AsyncState as RightsManagementAsyncResult;

            if (rightsManagementAsyncResult == null || rightsManagementAsyncResult == this)
            {
                if (this.saveContextCallback != null)
                {
                    this.saveContextCallback(base.AsyncState);
                }
                RmsClientManager.ADSession = this.adSession;
                return;
            }
            rightsManagementAsyncResult.InvokeSaveContextCallback();
        }
Beispiel #5
0
        internal void AddBreadCrumb(Constants.State value)
        {
            RightsManagementAsyncResult rightsManagementAsyncResult = base.AsyncState as RightsManagementAsyncResult;

            if (rightsManagementAsyncResult == null || rightsManagementAsyncResult == this)
            {
                if (this.breadcrumbs == null)
                {
                    this.breadcrumbs = new Breadcrumbs <Constants.State>(32);
                }
                this.breadcrumbs.Drop(value);
                return;
            }
            rightsManagementAsyncResult.AddBreadCrumb(value);
        }
        public void InvokeCallbacks(T tenantId, object result)
        {
            IEnumerable <RightsManagementAsyncResult> enumerable;

            lock (this.syncRoot)
            {
                PerTenantQueryController <T> .SynchronizedQueue tenantQueue = this.GetTenantQueue(tenantId);
                enumerable = tenantQueue.DequeueAll();
                this.RemoveTenantQueue(tenantId);
            }
            foreach (RightsManagementAsyncResult state in enumerable)
            {
                ThreadPool.QueueUserWorkItem(delegate(object o)
                {
                    RightsManagementAsyncResult rightsManagementAsyncResult = (RightsManagementAsyncResult)o;
                    rightsManagementAsyncResult.AddBreadCrumb(Constants.State.PerTenantQueryControllerInvokeCallback);
                    rightsManagementAsyncResult.InvokeCallback(result);
                }, state);
            }
        }
 public bool EnqueueResult(T tenantId, RightsManagementAsyncResult result)
 {
     PerTenantQueryController <T> .SynchronizedQueue tenantQueue = this.GetTenantQueue(tenantId);
     return(tenantQueue.Enqueue(result));
 }
Beispiel #8
0
 internal RightsManagementAsyncResult(RmsClientManagerContext context, object callerState, AsyncCallback callerCallback) : base(null, callerState, RightsManagementAsyncResult.WrapCallbackWithUnhandledExceptionAndCrash(callerCallback))
 {
     ArgumentValidator.ThrowIfNull("context", context);
     this.context                         = context;
     this.adSession                       = RmsClientManager.ADSession;
     this.saveContextCallback             = RmsClientManager.SaveContextCallback;
     RmsClientManager.SaveContextCallback = null;
 }