private static bool WaitForPriority(DispatcherPriority priority) { const int defaultTimeout = 30000; // Schedule the ExitFrame operation to end the nested pump after the timeout trigger happens TimeoutFrame frame = new TimeoutFrame(); FrameTimer timeoutTimer = new FrameTimer(frame, defaultTimeout, TimeoutFrameOperationInstance, DispatcherPriority.Send); timeoutTimer.Start(); // exit after a priortity has been processed DispatcherOperation opExit = Dispatcher.CurrentDispatcher.BeginInvoke(priority, ExitFrameOperationInstance, frame); // Pump the dispatcher Dispatcher.PushFrame(frame); // abort the operations that did not get processed if (opExit.Status != DispatcherOperationStatus.Completed) { opExit.Abort(); } if (!timeoutTimer.IsCompleted) { timeoutTimer.Stop(); } return(!frame.TimedOut); }
private static object TimeoutFrameOperation(object obj) { TimeoutFrame frame = obj as TimeoutFrame; frame.Continue = false; frame.TimedOut = true; return(null); }
public TimeoutFrameTick(TimeoutFrame parent, ulong timerId) { this.parent = parent; this.timerId = timerId; }