public PumpDisabler(Dispatcher dispatcher) { this.dispatcher = dispatcher; this.disabled = this.dispatcher.DisableProcessing(); if (dispatcher.IsDisabled()) { disabledDispatchers[this.dispatcher]++; } else { disabledDispatchers.Add(dispatcher, 1); } }
public DispatcherProcessingDisabled DisableProcessing() { if (this != FromThread(Thread.CurrentThread)) throw new InvalidOperationException("The calling thread cannot access this object because a different thread owns it."); myDisableProcessingCount++; DispatcherProcessingDisabled ret = new DispatcherProcessingDisabled(); ret.myDispatcher = this; return ret; }
/// <summary> /// Disable the event processing of the dispatcher. /// </summary> /// <remarks> /// This is an advanced method intended to elliminate the chance of /// unrelated reentrancy. The effect of disabling processing is: /// 1) CLR locks will not pump messages internally. /// 2) No one is allowed to push a frame. /// 3) No message processing is permitted. /// </remarks> public DispatcherProcessingDisabled DisableProcessing() { VerifyAccess(); // Turn off processing. _disableProcessingCount++; DispatcherProcessingDisabled dpd = new DispatcherProcessingDisabled(); dpd._dispatcher = this; return dpd; }