Articles in categories

Now on Amazon

WPF alternative for Application.DoEvents

With the Dispatcher.PushFrame Method you can simulate the Application.DoEvents Method which is present in  System.Windows.Forms assembly.

My static DoEvents class:

using System.Windows.Threading;

namespace Stieven.Utils
  public static class DoEvents
    public static void Do()
      DispatcherFrame frame = new DispatcherFrame();
          new DispatcherOperationCallback(ExitFrame), frame);

    public static object ExitFrame(object f)
      ((DispatcherFrame)f).Continue = false;

      return null;

Usage in code:


Better is to use somekind of (background) thread but for simple things this will do.