Open BillWagner opened 9 years ago
This could be available as a refactoring operation for any await
expression. In addition some cases may be identified with a diagnostic. Here is my list of [currently one] such case:
await
expressions appear in sequence, the first one can almost always use ConfigureAwait(false)
.When two await expressions appear in sequence, the first one can almost always use ConfigureAwait(false).
you mean the second one?
No, the first one. If all you are going to do is start a new task, why would you need to do so from a particular thread?
AFAIK, threading and asynchronous programming is not 100% related but I could be wrong. If you do the following under any context which has SynchronizationContext
(e.g. ASP.NET, WPF, etc.), I'm sure you will get into trouble (assuming that GetAsync method will perform asynchronously):
var foo = await _httpClient.GetAsync("http://localhost:5000").ConfigureAwait(false);
// ... other code which is UI related if under WPF or HttpContext related code if under ASP.NET
As already written here https://github.com/DotNetAnalyzers/Proposals/issues/26 this is tricky, but an important item to try and catch.