DispatcherFrame 类

定义

表示 .. 中的 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
继承
DispatcherFrame

示例

以下示例演示如何使用 a DispatcherFrame 实现与 Windows 窗体 DoEvents 方法类似的结果。

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

注解

DispatcherFrame 对象通常分为两个类别:

  • 长时间运行的常规用途帧仅在指示时退出。 请求这些帧时应退出。

  • 短运行,非常具体的帧,在满足重要条件时退出。 当请求这些帧是为了等待满足其退出条件时,这些帧可能会考虑不退出。 这些帧应具有与其关联的超时。

XAML 文本用法

不能在 XAML 中使用此托管类。

构造函数

名称 说明
DispatcherFrame()

初始化 DispatcherFrame 类的新实例。

DispatcherFrame(Boolean)

使用指定的退出请求标志初始化类的新实例 DispatcherFrame

属性

名称 说明
Continue

获取或设置一个值,该值指示是否应继续。DispatcherFrame

Dispatcher

获取与此DispatcherDispatcherObject关联的值。

(继承自 DispatcherObject)

方法

名称 说明
CheckAccess()

确定调用线程是否有权访问此 DispatcherObject权限。

(继承自 DispatcherObject)
Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)
VerifyAccess()

强制调用线程有权访问此 DispatcherObject权限。

(继承自 DispatcherObject)

适用于

另请参阅