OneShotDispatcherTimer (Kawagoe.Threading)

Provides a one-shot timer integrated to the Dispatcher queue.

A OneShotDispatcherTimer instance will fire at most once after it has been started. When this occurs, the Fired event of the OneShotDispatcherTimer instance is raised.

Like DispatcherTimer, on top of which it is implemented, a OneShotDispatcherTimer instance is not guaranteed to raise its Fired event exactly when the duration of the timer occurs, but it is guaranteed not to raise the event before the duration occurs.

The same OneShotDispatcherTimer instance can be started multiple times. Starting has no effect if the timer has already been started and has not fired or has not been stopped since then.


private void StartTimer()
    OneShotDispatcherTimer timer = new OneShotDispatcherTimer();
    timer.Duration = TimeSpan.FromSeconds(5);
    timer.Fired += OnTimerFired;

private void OnTimerFired(object sender, EventArgs e)
    // ...

Last edited Aug 22, 2010 at 2:20 PM by andreassaudemont, version 8


No comments yet.