private static async Task Test() { IQueueWriter queueWriter = new FakeQueueWriter(); var enumerable = Enumerable.Range(1, 100).Select(i => $"Messsage {i}"); await enumerable.SafeParallelAsync(async msg => await queueWriter.Write(msg)); }
private static async Task Test2() { IQueueWriter queueWriter = new FakeQueueWriter(); var enumerable = Enumerable.Range(1, 100).Select(i => $"Messsage {i}"); var cancellationToken = new CancellationToken(); await enumerable.SafeParallelAsync(async msg => await queueWriter.Write(msg), cancellationToken : cancellationToken); }