Skip to main content

DispatcherTimer Class

Definition​

Assembly:Avalonia.Base
Package:Avalonia

A timer that is integrated into the Dispatcher queues, and will be processed after a given amount of time at a specified priority.

public class DispatcherTimer

Inheritance: object -> DispatcherTimer

Constructors​

NameDescription
DispatcherTimer (6 overloads)Creates a timer that uses Avalonia.Threading.Dispatcher.CurrentDispatcher to process the timer event at background priority.

DispatcherTimer overloads​

DispatcherTimer Constructor​

Creates a timer that uses Avalonia.Threading.Dispatcher.CurrentDispatcher to process the timer event at background priority.

public DispatcherTimer()

DispatcherTimer Constructor​

Creates a timer that uses Avalonia.Threading.Dispatcher.CurrentDispatcher to process the timer event at the specified priority.

public DispatcherTimer(Avalonia.Threading.DispatcherPriority priority)
Parameters​

priority Avalonia.Threading.DispatcherPriority

The priority to process the timer at.

DispatcherTimer Constructor​

Creates a timer that uses the specified Avalonia.Threading.Dispatcher to process the timer event at the specified priority.

public DispatcherTimer(Avalonia.Threading.DispatcherPriority priority, Avalonia.Threading.Dispatcher dispatcher)
Parameters​

priority Avalonia.Threading.DispatcherPriority

The priority to process the timer at.

dispatcher Avalonia.Threading.Dispatcher

The dispatcher to use to process the timer.

DispatcherTimer Constructor​

Creates a timer that uses the specified Avalonia.Threading.Dispatcher to process the timer event at the specified priority after the specified timeout.

public DispatcherTimer(TimeSpan interval, Avalonia.Threading.DispatcherPriority priority, Avalonia.Threading.Dispatcher dispatcher)
Parameters​

interval TimeSpan

The interval to tick the timer after.

priority Avalonia.Threading.DispatcherPriority

The priority to process the timer at.

dispatcher Avalonia.Threading.Dispatcher

The dispatcher to use to process the timer.

DispatcherTimer Constructor​

Creates a timer that uses the specified Avalonia.Threading.Dispatcher to process the timer event at the specified priority after the specified timeout and with the specified handler.

public DispatcherTimer(TimeSpan interval, Avalonia.Threading.DispatcherPriority priority, Avalonia.Threading.Dispatcher dispatcher, EventHandler callback)
Parameters​

interval TimeSpan

The interval to tick the timer after.

priority Avalonia.Threading.DispatcherPriority

The priority to process the timer at.

dispatcher Avalonia.Threading.Dispatcher

The dispatcher to use to process the timer.

callback EventHandler

The callback to call when the timer ticks.

Remarks​

This constructor immediately starts the timer.

DispatcherTimer Constructor​

Creates a timer that uses Avalonia.Threading.Dispatcher.CurrentDispatcher to process the timer event at the specified priority after the specified timeout and with the specified handler.

public DispatcherTimer(TimeSpan interval, Avalonia.Threading.DispatcherPriority priority, EventHandler callback)
Parameters​

interval TimeSpan

The interval to tick the timer after.

priority Avalonia.Threading.DispatcherPriority

The priority to process the timer at.

callback EventHandler

The callback to call when the timer ticks.

Remarks​

This constructor immediately starts the timer.

Methods​

NameDescription
RunNo summary available.
RunOnceRuns a method once, after the specified interval.
StartStarts the timer.
StopStops the timer.

Run Method​

public IDisposable Run(Func<bool> action, TimeSpan interval, Avalonia.Threading.DispatcherPriority priority)

Parameters​

action Func<bool>

interval TimeSpan

priority Avalonia.Threading.DispatcherPriority

Returns​

IDisposable

RunOnce Method​

Runs a method once, after the specified interval.

public IDisposable RunOnce(Action action, TimeSpan interval, Avalonia.Threading.DispatcherPriority priority)

Parameters​

action Action

The method to call after the interval has elapsed.

interval TimeSpan

The interval after which to call the method.

priority Avalonia.Threading.DispatcherPriority

The priority to use.

Returns​

IDisposable

An IDisposable used to cancel the timer.

Start Method​

Starts the timer.

public void Start()

Stop Method​

Stops the timer.

public void Stop()

Properties​

NameDescription
DispatcherGets the dispatcher this timer is associated with.
IntervalGets or sets the time between timer ticks.
IsEnabledGets or sets whether the timer is running.
TagAny data that the caller wants to pass along with the timer.

Dispatcher Property​

Gets the dispatcher this timer is associated with.

public Avalonia.Threading.Dispatcher Dispatcher { get; set; }

Interval Property​

Gets or sets the time between timer ticks.

public TimeSpan Interval { get; set; }

IsEnabled Property​

Gets or sets whether the timer is running.

public bool IsEnabled { get; set; }

Tag Property​

Any data that the caller wants to pass along with the timer.

public object Tag { get; set; }

Events​

NameDescription
TickOccurs when the specified timer interval has elapsed and the timer is enabled.

Tick Event​

Occurs when the specified timer interval has elapsed and the timer is enabled.

public event EventHandler Tick