> For the complete documentation index, see [llms.txt](https://docs.yarnspinner.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yarnspinner.dev/3.1/api/csharp/yarn.unity/yarn.unity.actionregistrationextension/yarn.unity.actionregistrationextension.addcommandhandler-35.md).

# AddCommandHandler\<T1, T2>(IActionRegistration,string,System.Func\<T1, T2, IEnumerator>)

Method in [ActionRegistrationExtension](/3.1/api/csharp/yarn.unity/yarn.unity.actionregistrationextension.md)

## Summary

Adds a command handler. Dialogue will pause execution after the command is called.

```csharp
public static void AddCommandHandler<T1, T2>(this IActionRegistration registration, string commandName, System.Func<T1, T2, IEnumerator> handler);
```

## Remarks

When this command handler has been added, it can be called from your Yarn scripts like so:

```
<<commandName param1 param2>>
```

If `handler` is a method that returns a `UnityEngine.Coroutine`, when the command is run, the [DialogueRunner](/3.1/api/csharp/yarn.unity/yarn.unity.dialoguerunner.md) will wait for the returned coroutine to stop before delivering any more content.

If `handler` is a method that returns an `System.Collections.IEnumerator`, when the command is run, the [DialogueRunner](/3.1/api/csharp/yarn.unity/yarn.unity.dialoguerunner.md) will start a coroutine using that method and wait for that coroutine to stop before delivering any more content.

## Parameters

| Name                                                                                                        | Description                                                                                                        |
| ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `string` commandName                                                                                        | The name of the command.                                                                                           |
| `Func<T1, T2, IEnumerator>` handler                                                                         | The [CommandHandler](/3.1/api/csharp/yarn/yarn.commandhandler.md) that will be invoked when the command is called. |
| [Yarn.Unity.IActionRegistration](/3.1/api/csharp/yarn.unity/yarn.unity.iactionregistration.md) registration |                                                                                                                    |
