Condividi tramite


Dispatcher.PushFrame(DispatcherFrame) Metodo

Definizione

Immette un ciclo di esecuzione.

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)

Parametri

frame
DispatcherFrame

Frame da elaborare per il dispatcher.

Attributi

Eccezioni

frame è null.

HasShutdownFinished è true

oppure

frame è in esecuzione in un oggetto diverso Dispatcher.

oppure

L'elaborazione del dispatcher è stata disabilitata.

Esempio

Nell'esempio seguente viene illustrato come utilizzare un DispatcherFrame oggetto per ottenere risultati simili al metodo Windows Form 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

Commenti

Un DispatcherFrame oggetto rappresenta un ciclo che elabora gli elementi di lavoro in sospeso.

Dispatcher elabora la coda degli elementi di lavoro in un ciclo. Il ciclo viene definito frame. Il ciclo iniziale viene in genere avviato dall'applicazione chiamando Run.

PushFrame immette un ciclo rappresentato dal parametro frame. A ogni iterazione del ciclo, controlla Dispatcher la Continue proprietà nella DispatcherFrame classe per determinare se il ciclo deve continuare o se deve essere arrestato.

DispatcherFrame consente di impostare la Continue proprietà in modo esplicito e rispetta la HasShutdownStarted proprietà in Dispatcher. Ciò significa che all'avvio dell'arresto Dispatcher , i fotogrammi che usano l'implementazione predefinita DispatcherFrame usciranno, che consente a tutti i fotogrammi annidati di uscire.

Si applica a

Vedi anche