Created
April 2, 2013 15:03
-
-
Save pedroreys/5292915 to your computer and use it in GitHub Desktop.
find the potential bug
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
public static class Foo | |
{ | |
private static async Task DelayAsync() | |
{ | |
await Task.Delay(1000); | |
} | |
public static void Test() | |
{ | |
var delayTask = DelayAsync(); | |
delayTask.Wait(); | |
} | |
} |
Nailed it, @juanplopes!
By the way, got the example from here: http://msdn.microsoft.com/en-us/magazine/jj991977.aspx
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If this is running in a synchronization context that ensures continuations run on the same thread (WinForms, for example), delayTask.Wait would hang the UI thread forever, not allowing the await Task.Delay to ever return.
This would cause a deadlock. I guess.