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"); }); }
public void InvokeOutOfGui(IBackgroundWorkerDelegate callback) { if (ThreadPool != null && IsInGuiThread()) { ThreadPool.Queue(callback); return; } callback(); }
public void Use(IBackgroundWorkerDelegate runnable) { Object[] oldValues = SetThreadLocals(); try { runnable(); } finally { RestoreThreadLocals(oldValues); } }
public void ExecuteBusy(IBackgroundWorkerDelegate busyDelegate) { IBusyToken token = AcquireBusyToken(); try { busyDelegate.Invoke(); } finally { token.Finished(); } }
public void ExecuteWithSecurityScopes(IBackgroundWorkerDelegate runnable, params ISecurityScope[] securityScopes) { ISecurityScope[] oldSecurityScopes = SecurityScopes; try { SecurityScopes = securityScopes; runnable(); } finally { SecurityScopes = oldSecurityScopes; } }
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); }
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(); } }); }
public void InvokeInGui(IBackgroundWorkerDelegate callback) { InvokeInGui(delegate(Object state) { callback(); }, null); }
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; } } }