Dispatcher.PushFrame(DispatcherFrame) Metódus

Definíció

Egy végrehajtási ciklust ad meg.

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)

Paraméterek

frame
DispatcherFrame

A kézbesítő feldolgozandó kerete.

Attribútumok

Kivételek

frame az null.

HasShutdownFinished van true

-vagy-

frame fut egy másik Dispatcher.

-vagy-

A kézbesítő feldolgozása le lett tiltva.

Példák

Az alábbi példa bemutatja, hogyan használható DispatcherFrame a Windows Forms DoEvents metódushoz hasonló eredmények eléréséhez.

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

Megjegyzések

Az a DispatcherFrame hurok, amely függőben lévő munkaelemeket dolgoz fel.

A kézbesítő egy ciklusban dolgozza fel a munkaelem-üzenetsort. A hurkot keretnek nevezzük. A kezdeti ciklust általában az alkalmazás kezdeményezi hívással Run.

PushFrame a paraméter frameáltal képviselt hurkot adja meg. A ciklus minden iterációjában a Dispatcher program ellenőrzi az Continue osztály tulajdonságát DispatcherFrame annak megállapításához, hogy a hurok folytatódik-e, vagy leáll.

DispatcherFrame lehetővé teszi a Continue tulajdonság explicit beállítását, és tiszteletben tartja a HasShutdownStarted tulajdonságot a Dispatcher. Ez azt jelenti, hogy a leállítás megkezdésekor az Dispatcher alapértelmezett DispatcherFrame implementációt használó keretek kilépnek, ami lehetővé teszi az összes beágyazott keret kilépését.

A következőre érvényes:

Lásd még