Dispatcher.PushFrame(DispatcherFrame) メソッド

定義

実行ループに入ります。

public:
 static void PushFrame(System::Windows::Threading::DispatcherFrame ^ frame);
[System.Security.SecurityCritical]
public static void PushFrame (System.Windows.Threading.DispatcherFrame frame);
public static void PushFrame (System.Windows.Threading.DispatcherFrame frame);
[<System.Security.SecurityCritical>]
static member PushFrame : System.Windows.Threading.DispatcherFrame -> unit
static member PushFrame : System.Windows.Threading.DispatcherFrame -> unit
Public Shared Sub PushFrame (frame As DispatcherFrame)

パラメーター

frame
DispatcherFrame

ディスパッチャーが処理するフレーム。

属性

例外

framenullです。

HasShutdownFinishedtrue です

  • または - frame が別の Dispatcher で実行されています。

  • または - ディスパッチャー処理が無効になっています。

次の例は、Windows フォーム DoEvents メソッドと同様の結果を得るために a DispatcherFrame を使用する方法を示しています。

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

注釈

A DispatcherFrame は、保留中の作業項目を処理するループを表します。

ディスパッチャーは、作業項目キューをループ内で処理します。 ループはフレームと呼ばれます。 最初のループは、通常、呼び出 Runしによってアプリケーションによって開始されます。

PushFrame は、パラメーターで表されるループを入力します frame。 ループの反復ごとに、クラスのDispatcherFrameプロパティがContinueチェックされ、Dispatcherループが続行されるかどうか、またはループが停止する必要があるかどうかを判断します。

DispatcherFrameでは、プロパティをContinue明示的に設定でき、HasShutdownStartedDispatcher. つまり、シャットダウンを Dispatcher 開始すると、既定 DispatcherFrame の実装を使用するフレームが終了し、入れ子になったフレームがすべて終了します。

適用対象

こちらもご覧ください