> ## Documentation Index
> Fetch the complete documentation index at: https://easyaf.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# DelayDispatcher

> Provides methods to reduce the number of events that are fired, usually so that rapid,             imperceptible changes are ignored.

## Definition

**Assembly:** CloudNimble.BlazorEssentials.dll

**Namespace:** CloudNimble.BlazorEssentials.Threading

**Inheritance:** System.Object

## Syntax

```csharp theme={"dark"}
CloudNimble.BlazorEssentials.Threading.DelayDispatcher
```

## Summary

Provides methods to reduce the number of events that are fired, usually so that rapid,
imperceptible changes are ignored.

## Remarks

Throttle() ensures that events are throttled by the interval specified.
Only the last event in the interval sequence of events fires.

Debounce() fires an event only after the specified interval has passed
in which no other pending event has fired. Only the last event in the
sequence is fired.

Adapted from [https://weblog.west-wind.com/posts/2017/Jul/02/Debouncing-and-Throttling-Dispatcher-Events](https://weblog.west-wind.com/posts/2017/Jul/02/Debouncing-and-Throttling-Dispatcher-Events).

## Constructors

### <Icon icon="hammer" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> .ctor

#### Syntax

```csharp theme={"dark"}
public DelayDispatcher()
```

### <Icon icon="hammer" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> .ctor <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

```csharp theme={"dark"}
public Object()
```

## Properties

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> DelayCount

The number of events that have been dropped in a given interval.

#### Syntax

```csharp theme={"dark"}
public int DelayCount { get; internal set; }
```

#### Property Value

Type: `int`

#### Remarks

This value is reset every time the built-in [Timer](https://learn.microsoft.com/dotnet/api/system.timers.timer) elapses.

### <Icon icon="tag" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> TimerStarted

The [DateTime](https://learn.microsoft.com/dotnet/api/system.datetime) that a new [Timer](https://learn.microsoft.com/dotnet/api/system.timers.timer) was started, in UTC.

#### Syntax

```csharp theme={"dark"}
public System.DateTime TimerStarted { get; internal set; }
```

#### Property Value

Type: `System.DateTime`

## Methods

### <Icon icon="function" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> Debounce

Debounce an event by resetting the event timeout every time the event is
fired. The behavior is that the Action passed is fired only after events
stop firing for the given timeout period.

Use Debounce when you want events to fire only after events stop firing
after the given interval timeout period.

Wrap the logic you would normally use in your event code into
the  Action you pass to this method to debounce the event.
Example: [https://gist.github.com/RickStrahl/0519b678f3294e27891f4d4f0608519a](https://gist.github.com/RickStrahl/0519b678f3294e27891f4d4f0608519a)

#### Syntax

```csharp theme={"dark"}
public void Debounce(int interval, System.Action<object> action, object param = null)
```

#### Parameters

| Name       | Type                    | Description                                                                                                                                                                    |
| ---------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `interval` | `int`                   | An [Int32](https://learn.microsoft.com/dotnet/api/system.int32) specifying the [Timer](https://learn.microsoft.com/dotnet/api/system.timers.timer) duration (in milliseconds). |
| `action`   | `System.Action<object>` | The [Action](https://learn.microsoft.com/dotnet/api/system.action) to fire when the [Timer](https://learn.microsoft.com/dotnet/api/system.timers.timer) elapses.               |
| `param`    | `object`                | Any optional parameters to pass to the *action*.                                                                                                                               |

### <Icon icon="function" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> Dispose

#### Syntax

```csharp theme={"dark"}
public void Dispose()
```

### <Icon icon="code-fork" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> Equals <Badge color="gray">Inherited</Badge> <Badge color="orange">Virtual</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

```csharp theme={"dark"}
public virtual bool Equals(object obj)
```

#### Parameters

| Name  | Type      | Description |
| ----- | --------- | ----------- |
| `obj` | `object?` | -           |

#### Returns

Type: `bool`

### <Icon icon="thumbtack" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> Equals <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

```csharp theme={"dark"}
public static bool Equals(object objA, object objB)
```

#### Parameters

| Name   | Type      | Description |
| ------ | --------- | ----------- |
| `objA` | `object?` | -           |
| `objB` | `object?` | -           |

#### Returns

Type: `bool`

### <Icon icon="code-fork" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> GetHashCode <Badge color="gray">Inherited</Badge> <Badge color="orange">Virtual</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

```csharp theme={"dark"}
public virtual int GetHashCode()
```

#### Returns

Type: `int`

### <Icon icon="function" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> GetType <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

```csharp theme={"dark"}
public System.Type GetType()
```

#### Returns

Type: `System.Type`

### <Icon icon="function" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> MemberwiseClone <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

```csharp theme={"dark"}
protected internal object MemberwiseClone()
```

#### Returns

Type: `object`

### <Icon icon="thumbtack" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> ReferenceEquals <Badge color="gray">Inherited</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

```csharp theme={"dark"}
public static bool ReferenceEquals(object objA, object objB)
```

#### Parameters

| Name   | Type      | Description |
| ------ | --------- | ----------- |
| `objA` | `object?` | -           |
| `objB` | `object?` | -           |

#### Returns

Type: `bool`

### <Icon icon="function" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> Throttle

This method throttles events by allowing only 1 event to fire for the given
timeout period. Only the last event fired is handled - all others are ignored.
Throttle will fire events every timeout ms even if additional events are pending.

Use Throttle where you need to ensure that events fire at given intervals.

#### Syntax

```csharp theme={"dark"}
public void Throttle(int interval, System.Action<object> action, object param = null)
```

#### Parameters

| Name       | Type                    | Description                                                                                                                                                                    |
| ---------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `interval` | `int`                   | An [Int32](https://learn.microsoft.com/dotnet/api/system.int32) specifying the [Timer](https://learn.microsoft.com/dotnet/api/system.timers.timer) duration (in milliseconds). |
| `action`   | `System.Action<object>` | The [Action](https://learn.microsoft.com/dotnet/api/system.action) to fire when the [Timer](https://learn.microsoft.com/dotnet/api/system.timers.timer) elapses.               |
| `param`    | `object`                | Any optional parameters to pass to the *action*.                                                                                                                               |

### <Icon icon="code-fork" iconType="duotone" color="#419AC5" size={24} className="mr-2" /> ToString <Badge color="gray">Inherited</Badge> <Badge color="orange">Virtual</Badge>

<Note>Inherited from `object`</Note>

#### Syntax

```csharp theme={"dark"}
public virtual string ToString()
```

#### Returns

Type: `string?`

## Related APIs

* System.IDisposable
