.Net 5 – Asp.Net still has no SynchronizationContext?

I would like to know if .Net 5 based ASP.Net applications still has no SynchronizationContexts as mentioned here so I can continue to not write ConfigureAwait(false) or should I start sprinkling it all over?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

No, ASP.NET does not have a sync-context any more, and is extremely unlikely to ever regain one without a huge fight. You could verify this yourself by testing whether SynchronizationContext.Current has a value.

That said, if you’re writing application level code, if there was a sync-context, you probably shouldn’t be suppressing it; only library code should usually suppress sync-context, and library code should probably not make assumptions about the host environment, meaning: in library code you should probably add ConfigureAwait(false) manually if you don’t want sync-context.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x