Dispatcher.PushFrame(DispatcherFrame) Method

Definition

Escribe un bucle de ejecución.Enters an execute loop.

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

Parameters

frame
DispatcherFrame

Fotograma del distribuidor que se va a procesar.The frame for the dispatcher to process.

Attributes

Exceptions

frame es null.frame is null.

HasShutdownFinished es true.HasShutdownFinished is true

O bien-or- frame se ejecuta en un objeto Dispatcher diferente.frame is running on a different Dispatcher.

O bien-or- Se ha deshabilitado el procesamiento del distribuidor.Dispatcher processing has been disabled.

Examples

En el ejemplo siguiente se muestra cómo usar un DispatcherFrame para conseguir resultados similares como Windows FormsWindows Forms método DoEvents.The following example shows how to use a DispatcherFrame to achieve similar results as the Windows FormsWindows 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 representa un bucle que procesa los elementos de trabajo pendientes.A DispatcherFrame represents a loop that processes pending work items.

El distribuidor procesa la cola de elementos de trabajo en un bucle.The Dispatcher processes the work item queue in a loop. El bucle se conoce como marco.The loop is referred to as a frame. Normalmente, la aplicación inicia el bucle inicial llamando a Run.The initial loop is typically initiated by the application by calling Run.

PushFrame entra en un bucle representado por el parámetro frame.PushFrame enters a loop represented by the parameter frame. En cada iteración del bucle, el Dispatcher comprobará la propiedad Continue en la clase DispatcherFrame para determinar si el bucle debe continuar o si debe detenerse.At each iteration of the loop, the Dispatcher will check the Continue property on the DispatcherFrame class to determine whether the loop should continue or if it should stop.

DispatcherFrame permite establecer explícitamente la propiedad Continue y respeta la propiedad HasShutdownStarted en el Dispatcher.DispatcherFrame allows for the Continue property to be set explicitly and it respects the HasShutdownStarted property on the Dispatcher. Esto significa que cuando el Dispatcher comienza a cerrarse, se cerrarán los fotogramas que usan la implementación de DispatcherFrame predeterminada, lo que permite que todos los marcos anidados salgan.This means when the Dispatcher starts to shut down, frames that use the default DispatcherFrame implementation will exit, which enables all nested frames to exit.

Applies to

See also