Dispatcher.PushFrame(DispatcherFrame) Metoda

Definice

Zadá smyčku execute.

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)

Parametry

frame
DispatcherFrame

Rámec pro zpracování dispečera.

Atributy

Výjimky

frame je null.

HasShutdownFinished je true

-nebo- frame běží na jiném Dispatcher.

-nebo- Zpracování dispečeru bylo zakázané.

Příklady

Následující příklad ukazuje, jak použít DispatcherFrame k dosažení podobných výsledků jako model Windows Forms DoEvents metoda.

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

Poznámky

A DispatcherFrame představuje smyčku, která zpracovává čekající pracovní položky.

Dispečer zpracovává frontu pracovních položek ve smyčce. Smyčka se označuje jako rámec. Počáteční smyčka je obvykle inicializována aplikací voláním Run.

PushFrame zadá smyčku reprezentovanou parametrem frame. Při každé iteraci smyčky zkontroluje Dispatcher Continue vlastnost DispatcherFrame třídy a určí, jestli má smyčka pokračovat nebo jestli by se měla zastavit.

DispatcherFrameContinue umožňuje, aby vlastnost byla nastavena explicitně a respektuje HasShutdownStarted vlastnost v objektu Dispatcher. To znamená, že když Dispatcher se začne vypnout, snímky, které používají výchozí DispatcherFrame implementaci, se ukončí, což umožní ukončení všech vnořených rámců.

Platí pro

Viz také