<PackageReference Include="Nito.AsyncEx.Coordination" Version="5.1.2" />

Nito.AsyncEx.PauseToken

public struct PauseToken
A type that allows an operation to be cooperatively paused.
public bool CanBePaused { get; }

Whether this token can ever possibly be paused.

public bool IsPaused { get; }

Whether or not this token is in the paused state.

public void WaitWhilePaused()

Synchronously waits until the pause token is not paused.

Synchronously waits until the pause token is not paused, or until this wait is canceled by the cancellation token.

Asynchronously waits until the pause token is not paused.

Asynchronously waits until the pause token is not paused, or until this wait is canceled by the cancellation token.