Skip to content

Instantly share code, notes, and snippets.

@mariusGundersen
Created October 21, 2018 10:58
Show Gist options
  • Select an option

  • Save mariusGundersen/b552f99f4f2703a00b461c1ce4d11df0 to your computer and use it in GitHub Desktop.

Select an option

Save mariusGundersen/b552f99f4f2703a00b461c1ce4d11df0 to your computer and use it in GitHub Desktop.

Revisions

  1. mariusGundersen created this gist Oct 21, 2018.
    11 changes: 11 additions & 0 deletions Example2.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    using System.Runtime.CompilerServices;
    using System.Threading.Tasks;

    // Example 2: await anything
    public static TaskAwaiter<T> GetAwaiter<T>(this T nonAwaitable)
    => Task.FromResult(nonAwaitable).GetAwaiter();

    // Now we can write code like this
    await "Hello world";
    await 100;
    await true;