C# / .NET Bug Hunt Hard +35 XP
Deadlock Risk
This async code can deadlock in ASP.NET.
C# / .NETFind the bug
1
public string GetData() {2
return GetDataAsync().Result;3
} The bug is on line 2
Select the correct fix
Show answer and explanation
Answer: Both A and B fix it
.Result blocks synchronously and can deadlock when the async method tries to resume on the captured context. Use async/await throughout.
Hint: Blocking on async code is dangerous.
What this challenge tests
Bug Hunt in C# / .NET: async, deadlock.