Happy stress free coding

Feb 19, 2012

WPF–forcing all pending updates

Sometimes the delayed update of bindings in WPF gets in your way. This is how you can force all pending Dispatcher things to run NOW:

public static void DoEvents()
{
  DispatcherFrame frame = new DispatcherFrame();
  Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
     new DispatcherOperationCallback(ExitFrame), frame);
  Dispatcher.PushFrame(frame);
}

public static object ExitFrame(object f)
{
  ((DispatcherFrame)f).Continue = false;
  return null;
}

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]



<< Home