public PumpDisabler(Dispatcher dispatcher) { this.dispatcher = dispatcher; this.disabled = this.dispatcher.DisableProcessing(); if (dispatcher.IsDisabled()) { disabledDispatchers[this.dispatcher]++; } else { disabledDispatchers.Add(dispatcher, 1); } }
/// <summary> /// Equivalent to DoEvents /// </summary> /// <seealso cref="http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatcher.pushframe.aspx"/> public static void DoEvents(this Dispatcher dispatcher) { if (dispatcher.IsDisabled()) { return; } var frame = new DispatcherFrame(); dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action <DispatcherFrame>((p) => { p.Continue = false; }), frame); Dispatcher.PushFrame(frame); }