WithCancellation

This commit is contained in:
neuecc
2020-05-08 03:48:46 +09:00
parent 61b798b6e9
commit 856a049dd0
4 changed files with 64 additions and 5 deletions

View File

@@ -32,17 +32,24 @@ namespace NetCoreSandbox
static async Task Main(string[] args)
{
var cts = new CancellationTokenSource();
await foreach (var item in UniTaskAsyncEnumerable.Range(1, 3).WithCancellation(cts.Token))
{
Console.WriteLine(item);
cts.Cancel();
}
await UniTaskAsyncEnumerable.Range(1, 3).ForEachAsync(x =>
/*
.ForEachAsync(x =>
{
if (x == 2) throw new Exception();
Console.WriteLine(x);
});
*/