Created
May 25, 2018 10:55
-
-
Save atifaziz/1d1b1807596d19ae9da368ca8a56cd1a to your computer and use it in GitHub Desktop.
Demo of MoreLINQ's AwaitCompletion
This file contains 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
<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