TimerExtensions
Namespace: Wisej.Web.Markup
Assembly: Wisej.Framework (4.1.0.0)
Adds fluent markup extension methods to the Timer class.
- C#
- VB.NET
public class TimerExtensions
Public Class TimerExtensions
Methods
Enabled<TTimer>(timer, enabled)
Sets the Enabled property of the specified Timer.
| Parameter | Type | Description |
|---|---|---|
| TTimer | The type of the timer, must inherit from Timer. | |
| timer | TTimer | The timer for which to set the Enabled property. |
| enabled | Boolean | A boolean indicating whether the timer is enabled. |
Returns: TTimer. The modified timer with the updated Enabled property.
This method allows you to enable or disable the timer.
myTimer.Enabled(true);
Interval<TTimer>(timer, interval)
Sets the interval for the specified Timer.
| Parameter | Type | Description |
|---|---|---|
| TTimer | The type of the timer, must inherit from Timer. | |
| timer | TTimer | The timer for which to set the interval. |
| interval | Int32 | The interval to set for the timer. |
Returns: TTimer. The modified timer with the updated interval.
This method allows you to specify the interval between timer events.
myTimer.Interval(1000);
OnTick<TTimer>(timer, action)
Attaches an event handler for the Tick event of the specified Timer.
| Parameter | Type | Description |
|---|---|---|
| TTimer | The type of the timer, must inherit from Timer. | |
| timer | TTimer | The timer to attach the event handler to. |
| action | Action<TTimer> | An action to execute when the timer ticks. |
Returns: TTimer. The modified timer with the attached Tick event handler.
This method allows you to execute a custom action whenever the timer ticks.
myTimer.OnTick(t =>
{
AlertBox.Show("Timer ticked!");
});
Tag<TTimer>(timer, obj)
Sets the Tag property of the specified Timer.
| Parameter | Type | Description |
|---|---|---|
| TTimer | The type of the timer, must inherit from Timer. | |
| timer | TTimer | The timer for which to set the Tag property. |
| obj | Object | The object to associate with the timer. |
Returns: TTimer. The modified timer with the updated Tag property.
This method allows you to associate an arbitrary object with the timer.
myTimer.Tag("CustomTagData");