Demo of MoreLINQ's AwaitCompletion
<Query Kind="Expression"> | |
<NuGetReference Prerelease="true">morelinq</NuGetReference> | |
<Namespace>MoreLinq</Namespace> | |
<Namespace>MoreLinq.Experimental</Namespace> | |
</Query> | |
Enumerable | |
.Range(1, 5) | |
.Select(x => TimeSpan.FromSeconds(x)) | |
.RandomSubset(5) | |
.Index(1) | |
.Pipe(e => Console.WriteLine($"Job #{e.Key} will take {e.Value}")) | |
.AwaitCompletion(async (x, _) => { await Task.Delay(x.Value); return x; }, | |
(x, t) => t.Result) | |
// .AsSequential() | |
// .AsOrdered() | |
// .MaxConcurrency(2) | |
.Pipe(e => Console.WriteLine($"Job #{e.Key} completed")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment