Skip to content

Instantly share code, notes, and snippets.

@eugeneagafonov
Last active December 12, 2017 19:20
Show Gist options
  • Save eugeneagafonov/75a5b0d522a922f48a93599911592515 to your computer and use it in GitHub Desktop.
Save eugeneagafonov/75a5b0d522a922f48a93599911592515 to your computer and use it in GitHub Desktop.
async gotchas
using System;
using System.Threading.Tasks;
public class Program
{
public static async Task Main()
{
var t1 = MethodAsync();
// await Task.Delay(/*0*/1).ConfigureAwait(false);
var t2 = MethodAsync();
await Task.WhenAll(t1, t2);
}
async static Task MethodAsync()
{
Console.WriteLine($"Id: {Thread.CurrentThread.ManagedThreadId}");
for(int i = 0; i < 10; i++)
{
// await Task.Delay(/*0*/1);
Console.WriteLine(i);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment