소프트웨어 개발(SW Dev)/C#
Dispatcher Timer
flowhistory
2020. 7. 31. 17:02
지정된 시간 간격과 우선 순위로 처리되는 Dispatcher 큐로 통합되는 타이머.
0. MSDN
Assembly : WindowsBase.dll
Namespace : System.Windows.Threading
CONSTRUCTORS
DispatcherTimer() | DispatcherTimer 클래스의 새 인스턴스를 초기화합니다. |
DispatcherTimer(DispatcherPriority) |
지정된 우선 순위로 타이머 이벤트를 처리하는 DispatcherTimer 클래스의 새 인스턴스를 초기화합니다. |
DispatcherTimer(DispatcherPriority, Dispatcher) |
지정된 DispatcherTimer에서 지정된 우선 순위로 실행되는 Dispatcher 클래스의 새 인스턴스를 초기화합니다. |
DispatcherTimer(TimeSpan, DispatcherPriority, EventHandler, Dispatcher) |
지정된 시간 간격, 우선 순위, 이벤트 처리기 및 DispatcherTimer를 사용하는 Dispatcher 클래스의 새 인스턴스를 초기화합니다. |
1. DispaDispatcherTimer 사용
Dispatcher Timer
using System.Windows.Threading;
2. sample
Example 1
DispatcherTimer timer = new DispatcherTimer
{
Interval = new TimeSpan(0, 0, 1) // 1 sec
};
timer.Tick += Timer_Tick;
timer.Start();
private void Timer_Tick(object sender, EventArgs e)
{
...
}
Example 2
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromTicks(10000000); // 1 sec
timer.Tick += new EventHandler(timer_Tick);
timer.Start();
private void Timer_Tick(object sender, EventArgs e)
{
...
}
728x90