public static void ExitAllFrames() { Dispatcher dis = CurrentDispatcher; for (DispatcherFrame frame = dis.currentFrame; frame != null; frame = frame.ParentFrame) { if (frame.ExitOnRequest) { frame.Continue = false; } else { break; } } }
private void RunFrame(DispatcherFrame frame) { do { while (this.queueBits != 0) { for (int i = TopPriority; i > 0 && this.queueBits != 0; i--) { int currentBit = this.queueBits & (1 << i); if (currentBit != 0) { PokableQueue q = this.priorityQueues[i]; do { DispatcherOperation task; lock (q) { task = (DispatcherOperation)q.Dequeue(); } task.Invoke(); if (task.Status == DispatcherOperationStatus.Aborted) { this.hooks.EmitOperationAborted(task); } else { this.hooks.EmitOperationCompleted(task); } if (!frame.Continue) { return; } if (this.HasShutdownStarted) { this.PerformShutdown(); return; } lock (q) { if (q.Count == 0) { this.queueBits &= ~(1 << i); break; } } if (currentBit < (this.queueBits & ~currentBit)) { break; } }while (true); } } } this.hooks.EmitInactive(); PlatformInterface.Instance.Dispatcher.ProcessMessage(); if (this.HasShutdownStarted) { this.PerformShutdown(); return; } }while (frame.Continue); }
private void RunFrame(DispatcherFrame frame) { do { while (this.queueBits != 0) { for (int i = TopPriority; i > 0 && this.queueBits != 0; i--) { int currentBit = this.queueBits & (1 << i); if (currentBit != 0) { PokableQueue q = this.priorityQueues[i]; do { DispatcherOperation task; lock (q) { task = (DispatcherOperation)q.Dequeue(); } task.Invoke(); if (task.Status == DispatcherOperationStatus.Aborted) { this.hooks.EmitOperationAborted(task); } else { this.hooks.EmitOperationCompleted(task); } if (!frame.Continue) { return; } if (this.HasShutdownStarted) { this.PerformShutdown(); return; } lock (q) { if (q.Count == 0) { this.queueBits &= ~(1 << i); break; } } if (currentBit < (this.queueBits & ~currentBit)) { break; } } while (true); } } } this.hooks.EmitInactive(); PlatformInterface.Instance.Dispatcher.ProcessMessage(); if (this.HasShutdownStarted) { this.PerformShutdown(); return; } } while (frame.Continue); }
public static void PushFrame(DispatcherFrame frame) { if (frame == null) { throw new ArgumentNullException("frame"); } Dispatcher dis = CurrentDispatcher; if (dis.HasShutdownFinished) { throw new InvalidOperationException("The Dispatcher has shut down"); } if (frame.Running != null) { throw new InvalidOperationException("Frame is already running on a different dispatcher"); } if ((dis.flags & Flags.Disabled) != 0) { throw new InvalidOperationException("Dispatcher processing has been disabled"); } frame.ParentFrame = dis.currentFrame; dis.currentFrame = frame; frame.Running = dis; dis.RunFrame(frame); }