# LibTmux.Server.WaitForAsync

- **Module:** LibTmux
- **Package:** LibTmux
- **Language:** C#
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-dotnet/blob/cf34b255c896d19a97e7d7fabea58609c916012d/src/LibTmux/Server.Execution.cs#L139
- **Page:** https://libtmux.org/en/csharp/latest/reference/libtmux-server-waitforasync/

tmux command: [`wait-for`](/en/tmux/latest/manual/wait-for/)

```
LibTmux.Server.WaitForAsync(request: WaitForRequest, cancellationToken: CancellationToken) -> Task
```

Waits on, signals, locks, or unlocks a tmux channel.

Waiting blocks until something else signals the channel, so a call that
waits does not return on its own. A wait or a lock is not bounded by
<see cref="ServerConnectionOptions.CommandTimeout" />: it waits for another
client by design, and ending it would leave tmux holding its place.

## Parameters

- `request` (`WaitForRequest`): Which channel, and what to do with it.
- `cancellationToken` (`CancellationToken`): Cancels waiting for tmux's reply. For <see cref="TmuxWaitMode.Wait" />
this kills the client, and tmux before 3.8 keeps its queue entry, which
takes the next signal: a signal sent while nothing else waits is then
spent on that entry instead of waking the next wait. Prefer
<see cref="OpenWaitChannel" /> whenever a <see cref="TmuxWaitMode.Wait" />
needs a deadline. For
<see cref="TmuxWaitMode.Lock" /> cancelling never kills the client, since
tmux hands a released lock to whichever queued client is still alive: the
client keeps running, and a lock it goes on to acquire is released again
automatically once this call has already given up on it. A lock that is
never released therefore keeps one tmux client queued per cancelled call.
