queuetimer_DispatcherQueueTimer

DispatcherQueueTimer Class

Definition

Executes a task in a DispatcherQueue periodically after a time interval has elapsed.

In this article

public ref class DispatcherQueueTimer sealed

/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 327680)]

/// [Windows.Foundation.Metadata.DualApiPartition(version=167772164)]

/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]

/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]

/// [Windows.Foundation.Metadata.WebHostHidden]

class DispatcherQueueTimer sealed

/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 327680)]

/// [Windows.Foundation.Metadata.DualApiPartition(version=167772164)]

/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]

/// [Windows.Foundation.Metadata.WebHostHidden]

class DispatcherQueueTimer sealed

[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 327680)]

[Windows.Foundation.Metadata.DualApiPartition(version=167772164)]

[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]

[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]

[Windows.Foundation.Metadata.WebHostHidden]

public sealed class DispatcherQueueTimer

[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 327680)]

[Windows.Foundation.Metadata.DualApiPartition(version=167772164)]

[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]

[Windows.Foundation.Metadata.WebHostHidden]

public sealed class DispatcherQueueTimer

Public NotInheritable Class DispatcherQueueTimer

Inheritance

DispatcherQueueTimer

Windows 10 requirements

Device family

Windows 10 Fall Creators Update (introduced in 10.0.16299.0)

API contractWindows.Foundation.UniversalApiContract (introduced in v5.0)

Examples

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;

Remarks

The system guarantees to invoke the event handler only after the specified duration expires. However, there may be some delay before the tick handler is invoked if there are other pending work items in the queue.

Timer tasks run at a priority lower than idle.

Timers don’t keep the DispatcherQueue event loop alive. Timers created after the DispatcherQueue event loop has stopped will not be processed.

Properties

Gets and sets the interval for the timer.

Indicates whether the timer is repeating.

Indicates whether the timer is currently running.

Methods

Events

Event that fires when the timer Interval elapses.

Applies to

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值