# TimerExtensions

URL: https://docs.wisej.com/api/wisej.web.markup/extensions/wisej.web.markup.timerextensions

Version: 4.1
Namespace: **Wisej.Web.Markup**

Assembly: **Wisej.Framework** (4.1.0.0)

Adds [fluent markup](https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/markup/markup) extension methods to the [Timer](/api/wisej.web/other-components/wisej.web.timer) class.

- C# - VB.NET

```csharp
public class TimerExtensions
```

```visual
Public Class TimerExtensions
```

## Methods

### ![Static member](/img/api/static.png) Enabled<TTimer>(timer, enabled)

Sets the Enabled property of the specified [Timer](/api/wisej.web/other-components/wisej.web.timer) .

| Parameter | Type | Description | **TTimer** | | The type of the timer, must inherit from [Timer](/api/wisej.web/other-components/wisej.web.timer) . | **timer** | TTimer | The timer for which to set the Enabled property. | **enabled** | [Boolean](https://docs.microsoft.com/dotnet/api/system.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.

```csharp
myTimer.Enabled(true);
```

### ![Static member](/img/api/static.png) Interval<TTimer>(timer, interval)

Sets the interval for the specified [Timer](/api/wisej.web/other-components/wisej.web.timer) .

| Parameter | Type | Description | **TTimer** | | The type of the timer, must inherit from [Timer](/api/wisej.web/other-components/wisej.web.timer) . | **timer** | TTimer | The timer for which to set the interval. | **interval** | [Int32](https://docs.microsoft.com/dotnet/api/system.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.

```csharp
myTimer.Interval(1000);
```

### ![Static member](/img/api/static.png) OnTick<TTimer>(timer, action)

Attaches an event handler for the Tick event of the specified [Timer](/api/wisej.web/other-components/wisej.web.timer) .

| Parameter | Type | Description | **TTimer** | | The type of the timer, must inherit from [Timer](/api/wisej.web/other-components/wisej.web.timer) . | **timer** | TTimer | The timer to attach the event handler to. | **action** | [Action<TTimer>](https://docs.microsoft.com/dotnet/api/system.action-1) | 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.

```csharp
myTimer.OnTick(t =>
{
AlertBox.Show("Timer ticked!");
});
```

### ![Static member](/img/api/static.png) Tag<TTimer>(timer, obj)

Sets the Tag property of the specified [Timer](/api/wisej.web/other-components/wisej.web.timer) .

| Parameter | Type | Description | **TTimer** | | The type of the timer, must inherit from [Timer](/api/wisej.web/other-components/wisej.web.timer) . | **timer** | TTimer | The timer for which to set the Tag property. | **obj** | [Object](https://docs.microsoft.com/dotnet/api/system.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.

```csharp
myTimer.Tag("CustomTagData");
```
