TimerExtensions

Wisej.Web.Markup.TimerExtensions

Namespace: Wisej.Web.Markup

Assembly: Wisej.Framework (4.0.0.0)

Adds fluent markup extension methods to the Timer class.

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

The timer for which to set the Enabled property.

enabled

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

The timer for which to set the interval.

interval

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

The timer to attach the event handler to.

action

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

The timer for which to set the Tag property.

obj

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");

Last updated

Was this helpful?