GitHubUpdateManager() should use ConfigureAwait(false)
See original GitHub issueThis 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:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is now released in 2.7.34-pre
Thanks for the tip about CA2007, very helpful. This has been addressed in 0b8bcc19d650da1592a8cc26f7861b55a5a179bd and will be in the next release.