.NET Decompiler with support for PDB generation, ReadyToRun, Metadata (&more) - cross-platform!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

32 lines
666 B

using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
internal class AsyncForeach
{
public async Task<int> SumIntegers(IAsyncEnumerable<int> items, CancellationToken token)
{
int sum = 0;
await foreach (int item in items.WithCancellation(token)) {
if (token.IsCancellationRequested) {
break;
}
sum += item;
}
return sum;
}
public async Task<int> MaxInteger(IAsyncEnumerable<int> items)
{
int max = int.MinValue;
await foreach (int item in items) {
if (item > max) {
max = item;
}
}
return max;
}
}
}