Skip to main content
← Back to Code Arena
Hard Senior DebugIt async deadlock task synchronizationcontext

Debug It: The Async Deadlock

+300 XP · 20 min · attempt 1

Problem

The following ASP.NET method deadlocks when called on a thread with a SynchronizationContext:

  public string GetData()
  {
      return GetDataAsync().Result;
  }

  public async Task<string> GetDataAsync()
  {
      var data = await httpClient.GetStringAsync(url);
      return data;
  }

Name the property/method (single word) on Task that, when used to block on the async result, causes the deadlock. Enter just that one word.

Starter

// public string GetData() => GetDataAsync().Result;

Your answer

Playing as a guest — you'll be asked for a display name on submit. Log in to keep your XP across devices.