Created
September 24, 2019 13:53
-
-
Save aevitas/2cd2e4e579f12c2d1eb48b691e4cb053 to your computer and use it in GitHub Desktop.
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
static async Task Main(string[] args) | |
{ | |
await foreach (var num in GenerateNumbersAsync()) | |
{ | |
Console.WriteLine(num); | |
} | |
Console.ReadLine(); | |
} | |
public static async IAsyncEnumerable<int> GenerateNumbersAsync() | |
{ | |
for (int i = 0; i < 100; i++) | |
{ | |
await Task.Delay(TimeSpan.FromSeconds(1)); | |
yield return i; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment