CSharp · Console
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
public class Program
{
public static async Task Main()
{
var stopwatch = Stopwatch.StartNew();
await foreach (var pair in First().Zip(Second()))
Console.WriteLine(pair);
Console.WriteLine($"Duration: {stopwatch.ElapsedMilliseconds:#,0} msec");
static async IAsyncEnumerable<int> First()
{
for (int i = 1; i <= 5; i++) { await Task.Delay(100); yield return i; }
}
static async IAsyncEnumerable<int> Second()
{
for (int i = 1; i <= 5; i++) { await Task.Delay(100); yield return i; }
}
}
}