# LibTmux.Window.UnlinkAsync

- **Module:** LibTmux
- **Package:** LibTmux
- **Language:** C#
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-dotnet/blob/cf34b255c896d19a97e7d7fabea58609c916012d/src/LibTmux/Window.Links.cs#L65
- **Page:** https://libtmux.org/en/csharp/latest/reference/libtmux-window-unlinkasync/

tmux command: [`unlink-window`](/en/tmux/latest/manual/unlink-window/)

```
LibTmux.Window.UnlinkAsync(killIfLast: bool, cancellationToken: CancellationToken) -> Task

LibTmux.Window.UnlinkAsync(killIfLast: bool, expectedPaneIds: IReadOnlyList<PaneId>, cancellationToken: CancellationToken) -> Task
```

Removes this window's link to the session it was read through.

tmux refuses to unlink a window that belongs to only one session unless
it is allowed to destroy it. A guard in the native queue checks the
captured session/index still names this window before unlinking it.

## Parameters

- `killIfLast` (`bool`): Whether the window dies when this was its last link.
- `cancellationToken` (`CancellationToken`): Cancels the tmux command.
- `expectedPaneIds` (`IReadOnlyList<PaneId>`): The nonempty, distinct pane IDs expected in the window, in any order. (for `UnlinkAsync(killIfLast, expectedPaneIds, cancellationToken)`)

## Raises

- [`ArgumentException`](https://learn.microsoft.com/dotnet/api/system.argumentexception): The IDs are empty, duplicated, or exceed the native command byte budget. (for `UnlinkAsync(killIfLast, expectedPaneIds, cancellationToken)`)
- [`TmuxCommandException`](/en/csharp/latest/reference/libtmux-tmuxcommandexception/): The placement or pane membership changed, or tmux refused the unlink. (for `UnlinkAsync(killIfLast, expectedPaneIds, cancellationToken)`)
