Skip to content

Instantly share code, notes, and snippets.

@Majirefy
Created January 19, 2018 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Majirefy/34a54b38118dd07993dc3404e2d8820c to your computer and use it in GitHub Desktop.
Save Majirefy/34a54b38118dd07993dc3404e2d8820c to your computer and use it in GitHub Desktop.
UI Example for deadlock async code.
// My "library" method.
public static async Task<JObject> GetJsonAsync(Uri uri)
{
using (var client = new HttpClient())
{
var jsonString = await client.GetStringAsync(uri);
return JObject.Parse(jsonString);
}
}
// My "top-level" method.
public void Button1_Click(...)
{
var jsonTask = GetJsonAsync(...);
textBox1.Text = jsonTask.Result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment