Dispatcher.PushFrame(DispatcherFrame) Método

Definição

Insere um loop de execução.

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)

Parâmetros

frame
DispatcherFrame

O quadro para o dispatcher processar.

Atributos

Exceções

frame é null.

HasShutdownFinished é true

- ou - frame está em execução em um Dispatcher diferente.

- ou - Processamento do Dispatcher foi desabilitado.

Exemplos

O exemplo a seguir mostra como usar um DispatcherFrame para obter resultados semelhantes ao método Windows FormsDoEvents.

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

Comentários

Um DispatcherFrame representa um loop que processa itens de trabalho pendentes.

O Dispatcher processa a fila do item de trabalho em um loop. O loop é chamado de quadro. O loop inicial normalmente é iniciado pelo aplicativo chamando Run.

PushFrame insere um loop representado pelo parâmetro frame. Em cada iteração do loop, a Dispatcher propriedade será verificada Continue na DispatcherFrame classe para determinar se o loop deve continuar ou se ele deve parar.

DispatcherFrame permite que a Continue propriedade seja definida explicitamente e ela respeita a HasShutdownStarted propriedade no Dispatcher. Isso significa que, quando começar a Dispatcher desligar, os quadros que usam a implementação padrão DispatcherFrame serão encerrados, o que permite que todos os quadros aninhados sejam encerrados.

Aplica-se a

Confira também