Skip to content

Instantly share code, notes, and snippets.

@JoanM
Created December 20, 2016 11:05
Show Gist options
  • Save JoanM/15a956b968fca89fc0037240ed97b361 to your computer and use it in GitHub Desktop.
Save JoanM/15a956b968fca89fc0037240ed97b361 to your computer and use it in GitHub Desktop.
DoCurlAsync with only one ConfigureAwait
public async Task<string> DoCurlAsync()
{
using (var httpClient = new HttpClient())
using (var httpResonse = await httpClient.GetAsync("https://www.bynder.com").ConfigureAwait(false))
{
return await httpResonse.Content.ReadAsStringAsync();
}
}
@MikeVelso
Copy link

Actually @JoanM you are incorrect.
Using ConfigureAwait(false) is an anti pattern.
If your application is x async methods deep, you would need to add ConfigureAwait(false) to each and every awaitable down the call stack; otherwise you risk using a method incorrectly sooner or later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment