Skip to content

Instantly share code, notes, and snippets.

@ihordyrman
Created February 13, 2022 07:27
Show Gist options
  • Save ihordyrman/0b897e9e49a946ec62a94b4dcc0dcd2b to your computer and use it in GitHub Desktop.
Save ihordyrman/0b897e9e49a946ec62a94b4dcc0dcd2b to your computer and use it in GitHub Desktop.

Revisions

  1. ihordyrman created this gist Feb 13, 2022.
    32 changes: 32 additions & 0 deletions Program.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    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; }
    }
    }