# LibTmux.IControlModeSession.SendAsync

- **Module:** LibTmux
- **Package:** LibTmux
- **Language:** C#
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-dotnet/blob/cf34b255c896d19a97e7d7fabea58609c916012d/src/LibTmux/ControlMode/IControlModeSession.cs#L68
- **Page:** https://libtmux.org/en/csharp/latest/reference/libtmux-icontrolmodesession-sendasync/

```
LibTmux.IControlModeSession.SendAsync(command: TmuxCommand, cancellationToken: CancellationToken) -> Task<IReadOnlyList<string>>
```

Runs one command on this client and reads what it answered.

tmux answers commands in the order it received them, so this is safe to
call concurrently: each caller gets its own answer rather than someone
else's. Cancelling stops the wait, not the command; tmux has already
been told. Foreground <c>run-shell</c>, its tmux command-name prefixes,
and <c>run</c> are rejected before dispatch because their output is not
framed as a command reply. Only direct background shell invocations are
accepted. Use <see cref="Server.RunShellAsync" /> to read shell text where
tmux returns it. A nonzero shell exit raises <see cref="TmuxCommandException" />;
<see cref="TmuxCommandException.Result" /> carries its exit status.

## Parameters

- `command` (`TmuxCommand`): The typed command to run.
- `cancellationToken` (`CancellationToken`): Stops waiting for the answer.

## Returns

The lines tmux printed, empty when it printed nothing.

## Raises

- [`ControlModeCommandException`](/en/csharp/latest/reference/libtmux-controlmodecommandexception/): Tmux reported the command failed.
- [`ArgumentException`](https://learn.microsoft.com/dotnet/api/system.argumentexception): The rendered command is too large for one bounded request.
- [`StaleServerGenerationException`](/en/csharp/latest/reference/libtmux-staleservergenerationexception/): The command targets a different tmux server generation.
- [`NotSupportedException`](https://learn.microsoft.com/dotnet/api/system.notsupportedexception): The command is a <c>run-shell</c> or <c>run</c> invocation without an
unambiguous direct background shell option.
- [`InvalidOperationException`](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception): The client is no longer running or has too many unanswered commands.
