• Download
  • Doc
  • Gallery
  • Success Stories
  • What's New
  • Contact
  • More...

Product:

  • Download
  • Documentation
  • Success Stories
  • What's New
  • Source code on GitHub
  • Home

Services:

  • SL Migration Package
  • Upload Your .XAP

Company:

  • Contact
follow us on twitter view source on GitHub
Show / Hide Table of Contents

Class DispatcherTimer

Provides a timer that is integrated into the Dispatcher queue, which is processed at a specified interval of time and at a specified priority. One scenario for this is to run code on the UI thread.

Inheritance
System.Object
DispatcherTimer
Namespace: System.Windows.Threading
Assembly: OpenSilver.dll
Syntax
public class DispatcherTimer : object
Examples

Here is how you can create and use a DispatcherTimer:

DispatcherTimer _dispatcherTimer;
//We create a new instance of DispatcherTimer:
_dispatcherTimer = new Dispatchertimer();
//we set the time between each tick of the DispatcherTimer to 100 milliseconds:
timer.Interval = new TimeSpan(0, 0, 0, 0, 100);
_dispatcherTimer.Tick += DispatcherTimer_Tick;
_dispatcherTimer.Start();
void DispatcherTimer_Tick(object sender, object e)
{
    //Some code to execute at each Tick of the DispatcherTimer.
}

When you want to stop the DispatcherTimer, you can use the following code:

    _dispatcherTimer.Stop();

Constructors

DispatcherTimer()

Initializes a new instance of the DispatcherTimer class.

Declaration
public DispatcherTimer()

Properties

Interval

Gets or sets the amount of time between timer ticks.

Declaration
public TimeSpan Interval { get; set; }
Property Value
Type Description
TimeSpan

IsEnabled

Gets a value that indicates whether the timer is running.

Declaration
public bool IsEnabled { get; }
Property Value
Type Description
System.Boolean

Methods

OnTick()

Raises the Tick event.

Declaration
protected void OnTick()

Start()

Starts the DispatcherTimer.

Declaration
public void Start()

Stop()

Stops the DispatcherTimer.

Declaration
public void Stop()

Events

Tick

Occurs when the timer interval has elapsed.

Declaration
public event EventHandler Tick
Event Type
Type Description
EventHandler

Extension Methods

ToJavaScriptObjectExtender.ToJavaScriptObject(Object)