question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GitHubUpdateManager() should use ConfigureAwait(false)

See original GitHub issue

This is just a suggestion.

GitHubUpdateManager uses a few “await”, but it should be using ConfigureAwait(false):

Suggested Code Change:

using (var client = new HttpClient() { BaseAddress = baseAddress }) {
  client.DefaultRequestHeaders.UserAgent.Add(userAgent);
  var response = await client.GetAsync(releasesApiBuilder.ToString()).ConfigureAwait(false);
  response.EnsureSuccessStatusCode();

  var releases = SimpleJson.DeserializeObject<List<Release>>(await response.Content.ReadAsStringAsync().ConfigureAwait(false));

This change will avoid a deadlock in a scenario where the caller of GitHubUpdateManager() waits synchronously such as:

  var mgr = GetUpdateManagerAsync().GetAwaiter().GetResult();

If the caller uses the UI thread to invoke like this, the UI thread will wait for the task to finish, while GitHubUpdateManager() awaits a task and resume on the same UI thread. However, the UI thread cannot resume GitHubUpdateManager() because it’s already waiting.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
caesaycommented, Jan 1, 2022

This is now released in 2.7.34-pre

1reaction
caesaycommented, Dec 31, 2021

Thanks for the tip about CA2007, very helpful. This has been addressed in 0b8bcc19d650da1592a8cc26f7861b55a5a179bd and will be in the next release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Why is writing ConfigureAwait(false) on every line with ...
As a general rule, yes. ConfigureAwait(false) should be used for every await unless the method needs its context.
Read more >
Should I use ConfigureAwait(true) or ConfigureAwait(false)?
If we set 'ConfigureAwait(true)' then the continuation task runs on the same thread used before the 'await' statement. If we set 'ConfigureAwait ......
Read more >
.NET: Don't use ConfigureAwait(false) | Gabe's Code
As a general rule, ConfigureAwait(false) should be used for every await unless the method needs its context. It's even what Stephen Cleary (a ......
Read more >
When to use ConfigureAwait(false) : r/dotnet
In application (not library) code, i.e., top level caller it seems like you never want ConfigureAwait(false) because you KNOW that usage will ......
Read more >
Why I no longer use ConfigureAwait(false)
In this case, I believe that using ConfigureAwait(false) for the purpose of not ... Run(async () => { await RunOneWorkflowAsync(); await ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found