private PerTenantQueryController <T> .SynchronizedQueue GetTenantQueue(T tenantId)
        {
            PerTenantQueryController <T> .SynchronizedQueue synchronizedQueue;
            lock (this.syncRoot)
            {
                if (this.dictionary.TryGetValue(tenantId, out synchronizedQueue))
                {
                    return(synchronizedQueue);
                }
                synchronizedQueue = new PerTenantQueryController <T> .SynchronizedQueue();

                this.dictionary.Add(tenantId, synchronizedQueue);
            }
            ExTraceGlobals.RightsManagementTracer.TraceDebug <T>((long)this.GetHashCode(), "Created a new queue for tenant {0}", tenantId);
            return(synchronizedQueue);
        }
        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));
 }