The following code will freeze forever.
public async Task DoSomethingAsync()
{
await Task.Delay(2000);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
DoSomethingAsync().Wait();
// Task.Delay(2000).Wait();
}
If I switch the call to DoSomethingAsync
with the commented out code, it behaves as expected. I suspect that somehow the nested awaits are causing a deadlock, but I'm not sure why, or how to fix it.