This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Immutable; | |
using System.Diagnostics; | |
using System.Threading; | |
using System.Threading.Channels; | |
using System.Threading.Tasks; | |
using System.Threading.Tasks.Dataflow; | |
namespace CustomChannels | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task<bool> WaitAsync(this AsyncAutoResetEvent source, | |
TimeSpan timeout, CancellationToken cancellationToken = default) | |
{ | |
if (timeout < TimeSpan.Zero) throw new ArgumentOutOfRangeException(nameof(timeout)); | |
if (timeout == Timeout.InfiniteTimeSpan) | |
{ | |
await source.WaitAsync(cancellationToken); return true; | |
} | |
cancellationToken.ThrowIfCancellationRequested(); |
NewerOlder