# LibTmux.TmuxHooks.SetAsync

- **Module:** LibTmux
- **Package:** LibTmux
- **Language:** C#
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-dotnet/blob/cf34b255c896d19a97e7d7fabea58609c916012d/src/LibTmux/Hooks/TmuxHooks.cs#L239
- **Page:** https://libtmux.org/en/csharp/latest/reference/libtmux-tmuxhooks-setasync/

```
LibTmux.TmuxHooks.SetAsync(request: SetHookRequest, cancellationToken: CancellationToken) -> Task<TmuxHook>

LibTmux.TmuxHooks.SetAsync(request: SetHooksRequest, cancellationToken: CancellationToken) -> Task<TmuxHook>
```

Sets one hook entry.

## Parameters

- `request` (`SetHookRequest`): Which hook to set, to what, and how. (for `SetAsync(request, cancellationToken) [overload 1]`)
- `cancellationToken` (`CancellationToken`): Cancels the tmux commands.
- `request` (`SetHooksRequest`): Which hook to set, to what, and how. (for `SetAsync(request, cancellationToken) [overload 2]`)

## Returns

The hook as tmux holds it afterwards.

## Raises

- [`TmuxOptionException`](/en/csharp/latest/reference/libtmux-tmuxoptionexception/): tmux rejected the hook or its command. (for `SetAsync(request, cancellationToken) [overload 1]`)
- [`TmuxOptionException`](/en/csharp/latest/reference/libtmux-tmuxoptionexception/): tmux rejected the hook or a command. (for `SetAsync(request, cancellationToken) [overload 2]`)
