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 per il dispatcher da elaborare.

Attributi

Eccezioni

frame è null.

HasShutdownFinished è true

-oppure- frame è in esecuzione su un oggetto Dispatcher diverso.

-oppure- L'elaborazione del dispatcher è stata disabilitata.

Esempio

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

Commenti

Rappresenta DispatcherFrame un ciclo che elabora elementi di lavoro in sospeso.

Dispatcher elabora la coda dell'elemento 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, l'oggetto Dispatcher verificherà la Continue proprietà nella DispatcherFrame classe per determinare se il ciclo deve continuare o se deve essere arrestato.

DispatcherFrame consente di impostare la proprietà in modo esplicito e rispetta la Continue HasShutdownStarted proprietà su Dispatcher. Ciò significa che all'avvio dell'arresto Dispatcher , i frame che usano l'implementazione predefinita DispatcherFrame verranno chiusi, in modo da consentire l'uscita di tutti i fotogrammi annidati.

Si applica a

Vedi anche