Linguaggio

DispatcherQueueTimer Classe

Definizione

Esegue periodicamente un'attività in dispatcherQueue 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 verificarsi un certo ritardo prima che venga richiamato il gestore tick se sono presenti altri elementi di lavoro in sospeso nella coda.

Le attività timer vengono eseguite con una 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à

Nome Descrizione
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

Nome Descrizione
Start()

Avvia il timer DispatcherQueue .

Stop()

Arresta il timer DispatcherQueue .

Eventi

Nome Descrizione
Tick

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

Si applica a