I mentioned in a previous article that one of the most common mistakes you can make with asynchronous programming is synchronization during asynchrony. Because the principle of asynchrony is that after an asynchronous method is used, all callers should be asynchronous. This article is my takeaway from trying to avoid this problem when using HttpClient.

.net Core takes you into the world of asynchrony — the asynchronous Programming Pit Crawl Guide. With it, mom won’t have to worry about me missing work anymore

directory

  • HttpClient is most prone to synchronization errors during asynchrony
  • The proposal supports a synchronous approach
  • Port to.NET 5
  • Source appreciation

HttpClient is most prone to synchronization errors during asynchrony

In the case of synchronization errors during async, HttpClient does not expose the synchronization interface, so when you want to use this class, you automatically use the following code.

/ / warning! The usage is incorrect
private static HttpClient _client = new 
Copy the code