DispatcherFrame Class

DispatcherFrame Class

 

Represents an execution loop in the Dispatcher.

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

System.Object
  System.Windows.Threading.DispatcherObject
    System.Windows.Threading.DispatcherFrame

public class DispatcherFrame : DispatcherObject

NameDescription
System_CAPS_pubmethodDispatcherFrame()

Initializes a new instance of the DispatcherFrame class.

System_CAPS_pubmethodDispatcherFrame(Boolean)

Initializes a new instance of the DispatcherFrame class, by using the specified exit request flag.

NameDescription
System_CAPS_pubpropertyContinue

Gets or sets a value that indicates whether this DispatcherFrame should continue.

System_CAPS_pubpropertyDispatcher

Gets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.)

NameDescription
System_CAPS_pubmethodCheckAccess()

Determines whether the calling thread has access to this DispatcherObject.(Inherited from DispatcherObject.)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethodVerifyAccess()

Enforces that the calling thread has access to this DispatcherObject.(Inherited from DispatcherObject.)

DispatcherFrame objects typically fall into two categories:

  • Long running, general purpose frames that exit only when instructed to. These frames should exit when they are requested.

  • Short running, very specific frames that exit when an important criteria is met. These frames may consider not to exit when they are requested in favor of waiting for their exit criteria to be met. These frames should have a time-out associated with them.

You cannot use this managed class in XAML.

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

[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public void DoEvents()
{
    DispatcherFrame frame = new DispatcherFrame();
    Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background,
        new DispatcherOperationCallback(ExitFrame), frame);
    Dispatcher.PushFrame(frame);
}

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

    return null;
}

.NET Framework
Available since 3.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft