DispatcherQueueTimer 클래스

정의

시간 간격이 경과한 후 DispatcherQueue 스레드에서 작업을 주기적으로 실행합니다.

public ref class DispatcherQueueTimer sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 327680)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class DispatcherQueueTimer final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 327680)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class DispatcherQueueTimer final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 327680)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class DispatcherQueueTimer
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 327680)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class DispatcherQueueTimer
Public NotInheritable Class DispatcherQueueTimer
상속
Object Platform::Object IInspectable DispatcherQueueTimer
특성

Windows 요구 사항

디바이스 패밀리
Windows 10 Fall Creators Update (10.0.16299.0에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v5.0에서 도입되었습니다.)

예제

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;

설명

시스템은 지정된 기간이 만료된 후에만 이벤트 처리기를 호출하도록 보장합니다. 그러나 큐에 보류 중인 다른 작업 항목이 있는 경우 틱 처리기가 호출되기까지 약간의 지연이 있을 수 있습니다.

타이머 작업은 유휴보다 낮은 우선 순위로 실행됩니다.

타이머는 DispatcherQueue 이벤트 루프를 활성 상태로 유지하지 않습니다. DispatcherQueue 이벤트 루프가 중지된 후에 만든 타이머는 처리되지 않습니다.

속성

Interval

타이머의 간격을 가져오고 설정합니다.

IsRepeating

타이머가 반복되는지 여부를 나타냅니다.

IsRunning

타이머가 현재 실행 중인지 여부를 나타냅니다.

메서드

Start()

타이머를 시작합니다.

Stop()

타이머를 중지합니다.

이벤트

Tick

타이머 간격 이 경과할 때 발생하는 이벤트입니다.

적용 대상