WithCancellation associates a CancellationToken with an IAsyncEnumerable<T> during await foreach. It returns a wrapper whose GetAsyncEnumerator passes the supplied token to the original sequence. section 14.3
Cancel an async iterator
Define the iterator parameter with [EnumeratorCancellation], then apply collection.WithCancellation(cancel.Token). The iterator must observe the token—for example, Task.Delay(1000, cancellationToken)—because the token is only a flag. Canceling before the loop starts can prevent subsequent values. section 14.3 section 14.8
await foreach(var item in collection.WithCancellation(token))
Use the extension directly in the await foreach clause to pass cancellation into asynchronous iteration. section 14.3
