/// <summary>Waits for the task to complete execution, pumping in the meantime.</summary> /// <param name="task">The task for which to wait.</param> /// <remarks>This method is intended for usage with Windows Presentation Foundation.</remarks> public static T WaitWithPumping <T>(this Task <T> task) { if (task == null) { throw new ArgumentNullException("task"); } DispatcherFrame nestedFrame = new DispatcherFrame(); task.ContinueWith <bool>((Task <T> _) => nestedFrame.Continue = false); Dispatcher.PushFrame(nestedFrame); return(task.Result); }
public void DoEvents() { Thread.Sleep(0); DispatcherFrame frame = new DispatcherFrame(); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback((o) => { ((DispatcherFrame)o).Continue = false; return(null); }), frame); Dispatcher.PushFrame(frame); }
private static void ProcessUITasks() { var frame = new DispatcherFrame(); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback( delegate { frame.Continue = false; return(null); }), null); Dispatcher.PushFrame(frame); }
public void DoEvents() { DispatcherFrame nestedFrame = new DispatcherFrame(); DispatcherOperation exitOperation = Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, exitFrameCallback, nestedFrame); Dispatcher.PushFrame(nestedFrame); if (exitOperation.Status != DispatcherOperationStatus.Completed) { exitOperation.Abort(); } }
static object Execute(Action<int> func, int amount) { var frame = new DispatcherFrame(); new Thread(() => { func.Invoke(amount); frame.Continue = false; }).Start(); Dispatcher.PushFrame(frame); return Dispatcher.Yield(); }
public static void DoEvents() { DispatcherFrame outerFrame = new DispatcherFrame(); Dispatcher.CurrentDispatcher.BeginInvoke((SendOrPostCallback) delegate(object arg) { DispatcherFrame innerFrame = arg as DispatcherFrame; innerFrame.Continue = false; }, DispatcherPriority.Background, outerFrame); Dispatcher.PushFrame(outerFrame); }
/// <summary> /// Runs a single queued action that was scheduled on the current dispatcher using <see cref="Dispatcher.BeginInvoke(Delegate, DispatcherPriority, object[])"/> /// </summary> /// <param name="priority">The priority in which the action was scheduled</param> private static void RunAsyncAction(DispatcherPriority priority = DispatcherPriority.ContextIdle) { DispatcherFrame frame = new DispatcherFrame(); Dispatcher.CurrentDispatcher.BeginInvoke(priority, new DispatcherOperationCallback(f => { ((DispatcherFrame)f).Continue = false; return(null); }), frame); Dispatcher.PushFrame(frame); }
public void Await(HouseDelegate method) { var frame = new DispatcherFrame(); this.Post(() => { method(); frame.Continue = false; }); Dispatcher.PushFrame(frame); // start the secondary dispatcher, pausing this code }
private static void WaitFor(TimeSpan time, DispatcherPriority priority) { DispatcherTimer timer = new DispatcherTimer(priority); timer.Tick += new EventHandler(OnDispatched); timer.Interval = time; DispatcherFrame dispatcherFrame = new DispatcherFrame(false); timer.Tag = dispatcherFrame; timer.Start(); Dispatcher.PushFrame(dispatcherFrame); }
public static void DoEvents() { var frame = new DispatcherFrame(); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(dispatcherFrame => { ((DispatcherFrame)dispatcherFrame).Continue = false; return(null); }), frame); Dispatcher.PushFrame(frame); }
public static void wait(double seconds) { var frame = new DispatcherFrame(); new Thread((ThreadStart)(() => { Thread.Sleep(TimeSpan.FromSeconds(seconds)); frame.Continue = false; })).Start(); Dispatcher.PushFrame(frame); }
public void ProcessUITasks() { var frame = new DispatcherFrame(); this.Dispatcher.Invoke(DispatcherPriority.Background, new DispatcherOperationCallback(delegate(object parameter) { frame.Continue = false; return(null); }), null); Dispatcher.PushFrame(frame); }
/// <summary> /// Synchronously processes all work items in the current dispatcher queue. /// </summary> /// <param name="minimumPriority"> /// The minimum priority. /// All work items of equal or higher priority will be processed. /// </param> public static void ProcessWorkItems(DispatcherPriority minimumPriority) { var frame = new DispatcherFrame(); // Queue a work item. Dispatcher.CurrentDispatcher.BeginInvoke( minimumPriority, exitFrameCallback, frame); // Force the work item to run. // All queued work items of equal or higher priority will be run first. Dispatcher.PushFrame(frame); }
void ThreadProc() { //create second window in background thread Window window2 = new Window2(); window2.Show(); //start WPF message loop DispatcherFrame frame = new DispatcherFrame(); Dispatcher.PushFrame(frame); }
public static void DoEvents(Dispatcher disp = null) { DispatcherFrame frame = new DispatcherFrame(); if (disp == null) { disp = Dispatcher.CurrentDispatcher; } disp.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(ExitFrame), frame); Dispatcher.PushFrame(frame); }
private void performFieldUpdate() { DispatcherFrame dispatcherFrame = new DispatcherFrame(); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Render, new DispatcherOperationCallback(delegate(object parameter) { dispatcherFrame.Continue = false; return(null); }), null); Dispatcher.PushFrame(dispatcherFrame); Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate { })); }
public static void ForceUIToUpdate() { var frame = new DispatcherFrame(); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Render, new DispatcherOperationCallback(delegate { frame.Continue = false; return(null); }), null); Dispatcher.PushFrame(frame); }
public static void DoEvents() { DispatcherFrame frame = new DispatcherFrame(); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(ExitFrames), frame); try { Dispatcher.PushFrame(frame); } catch (InvalidOperationException) { } }
public static void DoEvents() { DispatcherFrame frame = new DispatcherFrame(true); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, (SendOrPostCallback) delegate(object arg) { var f = arg as DispatcherFrame; f.Continue = false; }, frame); Dispatcher.PushFrame(frame); }
/// <summary>Waits for the task to complete execution, pumping in the meantime.</summary> /// <param name="task">The task for which to wait.</param> /// <remarks>This method is intended for usage with Windows Presentation Foundation.</remarks> public static void WaitWithPumping(this Task task) { if (task == null) { throw new ArgumentNullException("task"); } var nestedFrame = new DispatcherFrame(); task.ContinueWith(_ => nestedFrame.Continue = false); Dispatcher.PushFrame(nestedFrame); task.Wait(); }
private static void WaitFor(DispatcherPriority priority) { DispatcherTimer timer = new DispatcherTimer(priority); timer.Tick += new EventHandler(OnDispatched); DispatcherFrame dispatcherFrame = new DispatcherFrame(false); timer.Tag = dispatcherFrame; timer.Start(); Dispatcher.PushFrame(dispatcherFrame); //((DispatcherObject)this).Dispatcher.PushFrame(dispatcherFrame); }
private static void DoEvents() { DispatcherFrame f = new DispatcherFrame(); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, (SendOrPostCallback) delegate(object arg) { DispatcherFrame fr = arg as DispatcherFrame; fr.Continue = false; }, f); Dispatcher.PushFrame(f); }
protected virtual void doBackgroundGuiThreadWork() { m_WaitWindow = createWindow(); m_WaitWindow.Show(m_Left, m_Top, m_Width, m_Height); m_WaitWindowShownEvent.Set(); Dispatcher dispatcher = m_WaitWindow.DispatcherInstance; DispatcherFrame frame = new DispatcherFrame(); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(exitFrame), frame); Dispatcher.PushFrame(frame); }
private static void UpdateUI() { DispatcherFrame frame = new DispatcherFrame(); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Render, new DispatcherOperationCallback(delegate(object parameter) { frame.Continue = false; return(null); } ), null); Dispatcher.PushFrame(frame); }
public static void NonBlockingSleep(int timeInMilliseconds) { DispatcherFrame df = new DispatcherFrame(); new Thread((ThreadStart)(() => { Thread.Sleep(TimeSpan.FromMilliseconds(timeInMilliseconds)); df.Continue = false; })).Start(); Dispatcher.PushFrame(df); }
public void DoEvents() { var disp = GetDispatcher(); if (disp != null) { DispatcherFrame frame = new DispatcherFrame(); disp.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(ExitFrame), frame); Dispatcher.PushFrame(frame); } }
} // func RunServerReportAsync /// <summary></summary> /// <param name="frame"></param> /// <param name="message"></param> /// <returns></returns> public IDisposable BlockAllUI(DispatcherFrame frame, string message = null) { Thread.Sleep(200); // wait for finish if (frame.Continue) { return(null); // block ui } else { return(null); } } // proc BlockAllUI
public static void DoEvents() { DispatcherFrame frame = new DispatcherFrame(); var callback = new DispatcherOperationCallback(obj => { ((DispatcherFrame)obj).Continue = false; return(null); }); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, callback, frame); Dispatcher.PushFrame(frame); }
private static TResult PushFrame <TResult>(IDispatcherService dispatcher, Func <Task <TResult> > task) { return(dispatcher.Invoke(() => { var frame = new DispatcherFrame(); var frameTask = task().ContinueWith(x => { frame.Continue = false; return x.Result; }); ComponentDispatcher.PushModal(); Dispatcher.PushFrame(frame); ComponentDispatcher.PopModal(); return frameTask.Result; })); }
public static void DoEvents() { var frame = new DispatcherFrame(true); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Loaded, (SendOrPostCallback)(arg => { var f = (DispatcherFrame)arg; f.Continue = false; }), frame); Dispatcher.PushFrame(frame); }
public void DomainCollection_AddDomainObjectFromWorkerThread() { var dispatcher = Dispatcher.CurrentDispatcher; var frame = new DispatcherFrame(); var workerTask = new Task<bool>(() => { }); Dispatcher.PushFrame(frame); Assert.IsTrue(raisedCollectionChanged, "CollectionChanged event not raised."); }