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

# OrderedMessageDispatcher

> An [IMessageDispatcher](/simplemessagebus/api-reference/CloudNimble/SimpleMessageBus/Dispatch/IMessageDispatcher) implementation that processes the messages in the order the ...

## Definition

**Assembly:** CloudNimble.SimpleMessageBus.Dispatch.dll

**Namespace:** CloudNimble.SimpleMessageBus.Dispatch

**Inheritance:** System.Object

## Syntax

```csharp theme={"dark"}
CloudNimble.SimpleMessageBus.Dispatch.OrderedMessageDispatcher
```

## Summary

An [IMessageDispatcher](https://easyaf.nimbleapps.cloud/simplemessagebus/api-reference/CloudNimble/SimpleMessageBus/Dispatch/IMessageDispatcher.md) implementation that processes the messages in the order the [IMessageHandler](https://easyaf.nimbleapps.cloud/simplemessagebus/api-reference/CloudNimble/SimpleMessageBus/Core/IMessageHandler.md)IMessageHandlers\</see>
were registered with the Dependency Injection container.

## Remarks

This dispatcher ensures that message handlers are invoked sequentially in registration order. This is useful
when handler execution order matters, such as when one handler's output affects another handler's behavior.
Each handler completes before the next one begins, providing predictable execution flow but potentially
slower overall processing compared to parallel dispatching.

## Constructors

### &#x20;.ctor

Initializes a new instance of the [OrderedMessageDispatcher](https://easyaf.nimbleapps.cloud/simplemessagebus/api-reference/CloudNimble/SimpleMessageBus/Dispatch/OrderedMessageDispatcher.md) class.

#### Syntax

```csharp theme={"dark"}
public OrderedMessageDispatcher(System.Collections.Generic.IEnumerable<CloudNimble.SimpleMessageBus.Core.IMessageHandler> messageHandlers)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `messageHandlers` | `System.Collections.Generic.IEnumerable<CloudNimble.SimpleMessageBus.Core.IMessageHandler>` | The collection of message handlers to dispatch to. |

### &#x20;.ctor Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

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

## Methods

### &#x20;Dispatch

Sends the [MessageEnvelope](https://easyaf.nimbleapps.cloud/simplemessagebus/api-reference/CloudNimble/SimpleMessageBus/Core/MessageEnvelope.md) to the [IMessageHandler](https://easyaf.nimbleapps.cloud/simplemessagebus/api-reference/CloudNimble/SimpleMessageBus/Core/IMessageHandler.md)MessageHandlers\</see> registered to that type, for processing.

#### Syntax

```csharp theme={"dark"}
public System.Threading.Tasks.Task Dispatch(CloudNimble.SimpleMessageBus.Core.MessageEnvelope messageEnvelope)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `messageEnvelope` | `CloudNimble.SimpleMessageBus.Core.MessageEnvelope` | The [MessageEnvelope](https://easyaf.nimbleapps.cloud/simplemessagebus/api-reference/CloudNimble/SimpleMessageBus/Core/MessageEnvelope.md) instance to be processed. |

#### Returns

Type: `System.Threading.Tasks.Task`

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *messageEnvelope* is null. |

#### Remarks

Handlers are invoked sequentially in the order they were registered with the DI container.
If any handler throws an exception, subsequent handlers will not be invoked.

### &#x20;Equals Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

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

#### Parameters

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

#### Returns

Type: `bool`

### &#x20;Equals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

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

#### Parameters

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

#### Returns

Type: `bool`

### &#x20;GetHashCode Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

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

#### Returns

Type: `int`

### &#x20;GetType Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

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

#### Returns

Type: `System.Type`

### &#x20;MemberwiseClone Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

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

#### Returns

Type: `object`

### &#x20;ReferenceEquals Inherited

> [!NOTE]
>
> Inherited from `object`

#### Syntax

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

#### Parameters

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

#### Returns

Type: `bool`

### &#x20;ToString Inherited Virtual

> [!NOTE]
>
> Inherited from `object`

#### Syntax

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

#### Returns

Type: `string?`

## Related APIs

* CloudNimble.SimpleMessageBus.Dispatch.IMessageDispatcher


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.