Condividi tramite


DispatcherQueueTimer Classe

Definizione

Esegue un'attività in un oggetto DispatcherQueue periodicamente dopo che è trascorso un intervallo di tempo.

public ref class DispatcherQueueTimer sealed
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Foundation.LiftedContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class DispatcherQueueTimer final
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Foundation.WindowsAppSDKContract, 65536)]
class DispatcherQueueTimer final
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.LiftedContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class DispatcherQueueTimer
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.WindowsAppSDKContract), 65536)]
public sealed class DispatcherQueueTimer
Public NotInheritable Class DispatcherQueueTimer
Ereditarietà
Object Platform::Object IInspectable DispatcherQueueTimer
Attributi

Esempio

public void ConfigureRepeatingTimer()
{
    _queueController = DispatcherQueueController.CreateOnDedicatedThread();
    _queue = _queueController.DispatcherQueue;

    _repeatingTimer = _queue.CreateTimer ();
    _repeatingTimer.Interval = TimeSpan.FromSeconds(5);

    // The tick handler will be invoked repeatedly after every 5
    // seconds on the dedicated thread.
    _repeatingTimer.Tick += (s, e) =>
    {
        DoWork();
    };

    // Start the Timer
    _repeatingTimer.Start();
}

private DispatcherQueue _queue;
private DispatcherQueueController _queueController;
private DispatcherQueueTimer _repeatingTimer;

Commenti

Il sistema garantisce di richiamare il gestore eventi solo dopo la scadenza della durata specificata. Tuttavia, potrebbe esserci qualche ritardo prima che il gestore tick venga richiamato se sono presenti altri elementi di lavoro in sospeso nella coda.

Le attività timer vengono eseguite con priorità inferiore a quella inattiva.

I timer non mantengono attivo il ciclo di eventi DispatcherQueue . I timer creati dopo l'arresto del ciclo di eventi DispatcherQueue non verranno elaborati.

Proprietà

Interval

Ottiene e imposta l'intervallo per il timer.

IsRepeating

Ottiene o imposta un valore che indica se il timer è ripetuto.

IsRunning

Indica se il timer è attualmente in esecuzione.

Metodi

Start()

Avvia il timer DispatcherQueue .

Stop()

Arresta il timer DispatcherQueue .

Eventi

Tick

Evento che viene generato quando è trascorso l'intervallo timer DispatcherQueue.

Si applica a