C# Class WinRTXamlToolkit.Tools.BackgroundTimer

A timer that raises the Tick events on a background thread, similar to ThreadPoolTimer, but with API compatible with DispatcherTimer.
It was written in response to this SO question: Controlled non UI timer in metro app (.NET) (http://stackoverflow.com/questions/10493253/controlled-non-ui-timer-in-metro-app-net). The purpose was to have ticks on a background thread and have the same API as the DispatcherTimer. It also has an option to self adjust a bit to have an average frequency closer to what you would expect given the configured Interval. That said I was not aware of the ThreadPoolTimer, so it is possible it makes more sense to use that one. It is a bit strange that the two timers we get have different APIs though, so perhaps that is one case where using the BackgroundTimer makes a little bit of sense.
Inheritance: IDisposable
显示文件 Open project: xyzzer/WinRTXamlToolkit Class Usage Examples

Public Methods

Method Description
BackgroundTimer ( ) : System

Initializes a new instance of the BackgroundTimer class.

Dispose ( ) : void

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Start ( ) : void

Starts the BackgroundTimer.

Stop ( ) : void

Stops the BackgroundTimer. Waits for it to stop before returning.

StopNonBlocking ( ) : void

Stops the BackgroundTimer - non blocking.

Private Methods

Method Description
Run ( ) : void
RunAdjusted ( ) : void

Method Details

BackgroundTimer() public method

Initializes a new instance of the BackgroundTimer class.
public BackgroundTimer ( ) : System
return System

Dispose() public method

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public Dispose ( ) : void
return void

Start() public method

Starts the BackgroundTimer.
public Start ( ) : void
return void

Stop() public method

Stops the BackgroundTimer. Waits for it to stop before returning.
public Stop ( ) : void
return void

StopNonBlocking() public method

Stops the BackgroundTimer - non blocking.
public StopNonBlocking ( ) : void
return void