Last active
August 5, 2021 21:22
-
-
Save celsojr/24620fd6ba3e47219804e1e72cfda52d to your computer and use it in GitHub Desktop.
Simple custom awaiter
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
using System; | |
using System.Threading.Tasks; | |
using System.Runtime.CompilerServices; | |
static class Program | |
{ | |
static async Task Main() | |
{ | |
Console.WriteLine("One second pls..."); | |
await 1_000; // My custom type await :) | |
Console.WriteLine("Thank you for waiting!"); | |
} | |
static TaskAwaiter GetAwaiter(this int miliseconds) => | |
Task.Delay(miliseconds).GetAwaiter(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment