mirror of
https://github.com/Cysharp/UniTask.git
synced 2026-05-15 19:40:09 +00:00
WithCancellation
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user