# LibTmux.Pane.RunAsync

- **Module:** LibTmux
- **Package:** LibTmux
- **Language:** C#
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-dotnet/blob/cf34b255c896d19a97e7d7fabea58609c916012d/src/LibTmux/Pane.Running.cs#L27
- **Page:** https://libtmux.org/en/csharp/latest/reference/libtmux-pane-runasync/

```
LibTmux.Pane.RunAsync(command: string, timeout: TimeSpan, cancellationToken: CancellationToken) -> Task<PaneRunResult>

LibTmux.Pane.RunAsync(request: PaneRunRequest, cancellationToken: CancellationToken) -> Task<PaneRunResult>
```

Runs a shell command in the pane and waits for its exit status.

## Parameters

- `command` (`string`): The shell command. (for `RunAsync(command, timeout, cancellationToken)`)
- `timeout` (`TimeSpan`): How long to wait for it. (for `RunAsync(command, timeout, cancellationToken)`)
- `cancellationToken` (`CancellationToken`): Stops waiting. A command already sent keeps running, so cancelling then raises
<see cref="LibTmuxException" /> saying it may have run, not <see cref="OperationCanceledException" />,
which <see cref="Task.Wait()" /> and F#'s <c>Async.AwaitTask</c> replace with a bare
<see cref="TaskCanceledException" />.
- `request` (`PaneRunRequest`): The command and how long to wait. (for `RunAsync(request, cancellationToken)`)

## Returns

The exit status and what the command printed.

## Raises

- [`ArgumentException`](https://learn.microsoft.com/dotnet/api/system.argumentexception): <paramref name="command" /> is blank. (for `RunAsync(command, timeout, cancellationToken)`)
- [`TmuxPaneException`](/en/csharp/latest/reference/libtmux-tmuxpaneexception/): The pane is not at a POSIX shell, is in a mode, or its program has exited; or it changed during every read before the command was sent.
- [`TmuxObjectNotFoundException`](/en/csharp/latest/reference/libtmux-tmuxobjectnotfoundexception/): tmux no longer has the pane.
- [`LibTmuxException`](/en/csharp/latest/reference/libtmux-libtmuxexception/): The command's result could not be read, or its private files could not be deleted; inspect the failure before retrying.
- [`ArgumentOutOfRangeException`](https://learn.microsoft.com/dotnet/api/system.argumentoutofrangeexception): The timeout or output budget is invalid. (for `RunAsync(request, cancellationToken)`)
