https://msdn.microsoft.com/en-us/magazine/gg598924.aspx
It's a great article, and I'm aware that all details could not be covered because that would essentially involve pasting the source code of .NET framework. So quoting the text:
Each thread has a current context. If "Current" is null, then the thread's current context is "new SynchronizationContext()", by convention.
On the other hand, however:
By default, the current SynchronizationContext is captured at an await point, and this SynchronizationContext is used to resume after the await (more precisely, it captures the current SynchronizationContext unless it is null, in which case it captures the current TaskScheduler)
These two statements pretty much contradict each other, so I'm thinking this is the result of some simplification that has been made by the author (I'm fine with it).
Could anyone explain this? Code that might help in answering my question (look for syncCtx
variable), this piece of code is related to the second quote.
SynchronizationContext
. "By convention" simply captures the way synchronization contexts are handled, it's not a rule that forbids a null synchronization context. As for the code, it's publicly available - referencesource.microsoft.com/#mscorlib/system/threading/…. – Jiles