# TimerExtensions

Namespace: **Wisej.Web.Markup**

Assembly: **Wisej.Framework** (4.0.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.md) class.

{% tabs %}
{% tab title="C#" %}

```csharp
public class TimerExtensions
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class TimerExtensions
```

{% endtab %}
{% endtabs %}

## Methods

### ![](/files/lIX317sDtMTZJBi9oSIx) Enabled\<TTimer>(timer, enabled)

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

| Parameter   | Type                                                                           | Description                                                                                           |
| ----------- | ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- |
| **TTimer**  |                                                                                | The type of the timer, must inherit from [Timer](/api/wisej.web/other-components/wisej.web.timer.md). |
| **timer**   | [TTimer](/api/wisej.web.markup/extensions/wisej.web.markup.timerextensions.md) | 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](/api/wisej.web.markup/extensions/wisej.web.markup.timerextensions.md). The modified timer with the updated Enabled property.

This method allows you to enable or disable the timer.

```csharp

myTimer.Enabled(true);

```

### ![](/files/lIX317sDtMTZJBi9oSIx) Interval\<TTimer>(timer, interval)

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

| Parameter    | Type                                                                           | Description                                                                                           |
| ------------ | ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- |
| **TTimer**   |                                                                                | The type of the timer, must inherit from [Timer](/api/wisej.web/other-components/wisej.web.timer.md). |
| **timer**    | [TTimer](/api/wisej.web.markup/extensions/wisej.web.markup.timerextensions.md) | 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](/api/wisej.web.markup/extensions/wisej.web.markup.timerextensions.md). The modified timer with the updated interval.

This method allows you to specify the interval between timer events.

```csharp

myTimer.Interval(1000);

```

### ![](/files/lIX317sDtMTZJBi9oSIx) OnTick\<TTimer>(timer, action)

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

| Parameter  | Type                                                                           | Description                                                                                           |
| ---------- | ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- |
| **TTimer** |                                                                                | The type of the timer, must inherit from [Timer](/api/wisej.web/other-components/wisej.web.timer.md). |
| **timer**  | [TTimer](/api/wisej.web.markup/extensions/wisej.web.markup.timerextensions.md) | 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](/api/wisej.web.markup/extensions/wisej.web.markup.timerextensions.md). 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!");
});

```

### ![](/files/lIX317sDtMTZJBi9oSIx) Tag\<TTimer>(timer, obj)

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

| Parameter  | Type                                                                           | Description                                                                                           |
| ---------- | ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- |
| **TTimer** |                                                                                | The type of the timer, must inherit from [Timer](/api/wisej.web/other-components/wisej.web.timer.md). |
| **timer**  | [TTimer](/api/wisej.web.markup/extensions/wisej.web.markup.timerextensions.md) | 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](/api/wisej.web.markup/extensions/wisej.web.markup.timerextensions.md). The modified timer with the updated Tag property.

This method allows you to associate an arbitrary object with the timer.

```csharp

myTimer.Tag("CustomTagData");

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/api/wisej.web.markup/extensions/wisej.web.markup.timerextensions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
