DispatcherFrame DispatcherFrame DispatcherFrame DispatcherFrame Class

Definition

Represents an execution loop in the Dispatcher.

public ref class DispatcherFrame : System::Windows::Threading::DispatcherObject
public class DispatcherFrame : System.Windows.Threading.DispatcherObject
type DispatcherFrame = class
    inherit DispatcherObject
Public Class DispatcherFrame
Inherits DispatcherObject
Inheritance
DispatcherFrameDispatcherFrameDispatcherFrameDispatcherFrame

Examples

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;
}
<SecurityPermissionAttribute(SecurityAction.Demand, Flags := SecurityPermissionFlag.UnmanagedCode)>
Public Sub DoEvents()
	Dim frame As New DispatcherFrame()
	Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, New DispatcherOperationCallback(AddressOf ExitFrame), frame)
	Dispatcher.PushFrame(frame)
End Sub

Public Function ExitFrame(ByVal f As Object) As Object
	CType(f, DispatcherFrame).Continue = False

	Return Nothing
End Function

Remarks

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.

XAML Text Usage

You cannot use this managed class in XAML.

Constructors

DispatcherFrame() DispatcherFrame() DispatcherFrame() DispatcherFrame()

Initializes a new instance of the DispatcherFrame class.

DispatcherFrame(Boolean) DispatcherFrame(Boolean) DispatcherFrame(Boolean) DispatcherFrame(Boolean)

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

Properties

Continue Continue Continue Continue

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

Dispatcher Dispatcher Dispatcher Dispatcher

Gets the Dispatcher this DispatcherObject is associated with.

(Inherited from DispatcherObject)

Methods

CheckAccess() CheckAccess() CheckAccess() CheckAccess()

Determines whether the calling thread has access to this DispatcherObject.

(Inherited from DispatcherObject)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)
VerifyAccess() VerifyAccess() VerifyAccess() VerifyAccess()

Enforces that the calling thread has access to this DispatcherObject.

(Inherited from DispatcherObject)

Applies to

See Also