Ejemplo n.º 1
0
        protected void FireQueuedPropertyChangeEvents()
        {
            List <IBackgroundWorkerDelegate> queuedEvents = queuedEventsTL.Value;

            if (queuedEvents == null)
            {
                return;
            }
            queuedEventsTL.Value = null;
            Log.Info("ICacheModification.FlushInGui()");
            GuiThreadHelper.InvokeInGui(delegate()
            {
                Log.Info("ICacheModification.FlushWithinGui()");
                try
                {
                    for (int a = 0, size = queuedEvents.Count; a < size; a++)
                    {
                        IBackgroundWorkerDelegate queuedEvent = queuedEvents[a];
                        queuedEvent();
                    }
                }
                catch (Exception e)
                {
                    Log.Error(e);
                    throw;
                }
                Log.Info("ICacheModification.FlushWithinGui finished");
            });
        }
Ejemplo n.º 2
0
 public void InvokeOutOfGui(IBackgroundWorkerDelegate callback)
 {
     if (ThreadPool != null && IsInGuiThread())
     {
         ThreadPool.Queue(callback);
         return;
     }
     callback();
 }
Ejemplo n.º 3
0
 public void Use(IBackgroundWorkerDelegate runnable)
 {
     Object[] oldValues = SetThreadLocals();
     try
     {
         runnable();
     }
     finally
     {
         RestoreThreadLocals(oldValues);
     }
 }
Ejemplo n.º 4
0
        public void ExecuteBusy(IBackgroundWorkerDelegate busyDelegate)
        {
            IBusyToken token = AcquireBusyToken();

            try
            {
                busyDelegate.Invoke();
            }
            finally
            {
                token.Finished();
            }
        }
Ejemplo n.º 5
0
 public void ExecuteWithSecurityScopes(IBackgroundWorkerDelegate runnable, params ISecurityScope[] securityScopes)
 {
     ISecurityScope[] oldSecurityScopes = SecurityScopes;
     try
     {
         SecurityScopes = securityScopes;
         runnable();
     }
     finally
     {
         SecurityScopes = oldSecurityScopes;
     }
 }
Ejemplo n.º 6
0
        public void QueuePropertyChangeEvent(IBackgroundWorkerDelegate task)
        {
            if (!Active)
            {
                throw new Exception("Not supported if IsActive is 'false'");
            }
            List <IBackgroundWorkerDelegate> queuedEvents = queuedEventsTL.Value;

            if (queuedEvents == null)
            {
                queuedEvents         = new List <IBackgroundWorkerDelegate>();
                queuedEventsTL.Value = queuedEvents;
            }
            queuedEvents.Add(task);
        }
Ejemplo n.º 7
0
        public virtual void Queue(IBackgroundWorkerDelegate workerRunnable)
        {
            System.Threading.ThreadPool.QueueUserWorkItem(delegate(Object state)
            {
#if SILVERLIGHT
                try
                {
                    workerRunnable.Invoke();
                }
                catch (ThreadAbortException)
                {
                    // Intended blank
                }
                catch (Exception e)
                {
                    Log.Error(e);
                    throw;
                }
#else
                try
                {
                    workerRunnable.Invoke();
                }
                catch (ThreadAbortException)
                {
                    // Intended blank
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
#endif
                finally
                {
                    ThreadLocalCleanupController.CleanupThreadLocal();
                }
            });
        }
Ejemplo n.º 8
0
 public void InvokeInGui(IBackgroundWorkerDelegate callback)
 {
     InvokeInGui(delegate(Object state) { callback(); }, null);
 }
Ejemplo n.º 9
0
 public void ExecuteWithSecurityDirective(SecurityDirective securityDirective, IBackgroundWorkerDelegate runnable)
 {
     bool? securityActive = securityDirective.HasFlag(SecurityDirective.DISABLE_SECURITY) ? false : securityDirective
             .HasFlag(SecurityDirective.ENABLE_SECURITY) ? true : default(bool?);
     bool? entityActive = securityDirective.HasFlag(SecurityDirective.DISABLE_ENTITY_CHECK) ? false : securityDirective
             .HasFlag(SecurityDirective.ENABLE_ENTITY_CHECK) ? true : default(bool?);
     bool? serviceActive = securityDirective.HasFlag(SecurityDirective.DISABLE_SERVICE_CHECK) ? false : securityDirective
             .HasFlag(SecurityDirective.ENABLE_SERVICE_CHECK) ? true : default(bool?);
     bool? oldSecurityActive = null, oldEntityActive = null, oldServiceActive = null;
     if (securityActive != null)
     {
         oldSecurityActive = securityActiveTL.Value;
         securityActiveTL.Value = securityActive;
     }
     try
     {
         if (entityActive != null)
         {
             oldEntityActive = entityActiveTL.Value;
             entityActiveTL.Value = entityActive;
         }
         try
         {
             if (serviceActive != null)
             {
                 oldServiceActive = serviceActiveTL.Value;
                 serviceActiveTL.Value = serviceActive;
             }
             try
             {
                 runnable();
                 return;
             }
             finally
             {
                 if (serviceActive != null)
                 {
                     serviceActiveTL.Value = oldServiceActive;
                 }
             }
         }
         finally
         {
             if (entityActive != null)
             {
                 entityActiveTL.Value = oldEntityActive;
             }
         }
     }
     finally
     {
         if (securityActive != null)
         {
             securityActiveTL.Value = oldSecurityActive;
         }
     }
 }