Last active
December 12, 2017 19:20
-
-
Save eugeneagafonov/75a5b0d522a922f48a93599911592515 to your computer and use it in GitHub Desktop.
async gotchas
This file contains hidden or 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; | |
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