Dispatcher.PushFrame Method

Enters an execute loop.

Namespace: System.Windows.Threading
Assembly: WindowsBase (in windowsbase.dll)

public static void PushFrame (
	DispatcherFrame frame
public static void PushFrame (
	DispatcherFrame frame
public static function PushFrame (
	frame : DispatcherFrame
You cannot use methods in XAML.



The frame for the dispatcher to process.

Exception typeCondition


frame is a null reference (Nothing in Visual Basic).


HasShutdownFinished is true


frame is running on a different Dispatcher.


Dispatcher processing has been disabled.

A DispatcherFrame represents a loop that processes pending work items.

The Dispatcher processes the work item queue in a loop. The loop is referred to as a frame. The initial loop is typically initiated by the application by calling Run.

PushFrame enters a loop represented by the parameter frame. At each iteration of the loop, the Dispatcher will check the Continue property on the DispatcherFrame class to determine whether the loop should continue or if it should stop.

DispatcherFrame allows for the Continue property to be set explicitly and it respects the HasShutdownStarted property on the Dispatcher. This means when the Dispatcher starts to shut down, frames that use the default DispatcherFrame implementation will exit, which enables all nested frames to exit.

The following example shows how to use a DispatcherFrame to achieve similar results as the Windows Forms DoEvents method.

public void DoEvents()
    DispatcherFrame frame = new DispatcherFrame();
        new DispatcherOperationCallback(ExitFrame), frame);

public object ExitFrames(object f)
    ((DispatcherFrame)f).Continue = false;
    return null;

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0