DotNext.Threading by .NET Foundation and Contributors

<PackageReference Include="DotNext.Threading" Version="5.9.0" />

 AsyncBridge

public static class AsyncBridge
Allows to turn WaitHandle and CancellationToken into task.
public static int MaxPoolSize { get; set; }

Gets or sets the capacity of the internal pool used to create awaitable tasks returned from the public methods in this class.

Creates a task that will complete when any of the supplied tokens have canceled.

public static Task<CancellationToken> WaitAnyAsync(this ReadOnlySpan<CancellationToken> tokens, out Func interruption)

Creates a task that will complete when any of the supplied tokens have canceled.

public static ValueTask WaitAsync(this CancellationToken token, bool completeAsCanceled = false)

Obtains a task that can be used to await token cancellation.

public static ValueTask<bool> WaitAsync(this WaitHandle handle, TimeSpan timeout, CancellationToken token = default)

Obtains a task that can be used to await handle completion.

public static ValueTask WaitAsync(this WaitHandle handle, CancellationToken token = default)

Obtains a task that can be used to await handle completion.