Created
February 13, 2022 07:27
-
-
Save ihordyrman/0b897e9e49a946ec62a94b4dcc0dcd2b to your computer and use it in GitHub Desktop.
Int awaiting
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.Runtime.CompilerServices; | |
using System.Threading.Tasks; | |
public class Program | |
{ | |
public static async Task Main() | |
{ | |
Console.WriteLine(await 1); | |
} | |
} | |
public static class IntTaskExtensions | |
{ | |
public static IntAwaiter GetAwaiter(this int number) => new IntAwaiter(number); | |
public class IntAwaiter : INotifyCompletion | |
{ | |
private int result; | |
public IntAwaiter(int number) | |
{ | |
result = number + 1; | |
} | |
public bool IsCompleted => true; | |
public void OnCompleted(Action continuation) { } | |
public int GetResult() { return result; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment