Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

asp.net

.net-5

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?

like image 512
Leonardo Avatar asked Dec 07 '20 17:12

Leonardo


1 Answers

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.

like image 50
Marc Gravell Avatar answered Sep 25 '22 17:09

Marc Gravell