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

範例

以下範例展示了如何使用 來 DispatcherFrame 達成與 Windows Forms 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 中使用這個受管理類別。

建構函式

名稱 Description
DispatcherFrame()

初始化 DispatcherFrame 類別的新執行個體。

DispatcherFrame(Boolean)

透過指定的退出請求旗標初始化該類別的新 DispatcherFrame 實例。

屬性

名稱 Description
Continue

會取得或設定一個值,指示是否應該繼續此狀態 DispatcherFrame

Dispatcher

了解 Dispatcher 這與此 DispatcherObject 有關。

(繼承來源 DispatcherObject)

方法

名稱 Description
CheckAccess()

判斷呼叫執行緒是否能存取此 DispatcherObject

(繼承來源 DispatcherObject)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設哈希函式。

(繼承來源 Object)
GetType()

取得目前實例的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
ToString()

傳回表示目前 物件的字串。

(繼承來源 Object)
VerifyAccess()

強制呼叫執行緒能存取此 DispatcherObject

(繼承來源 DispatcherObject)

適用於

另請參閱