Posts

Showing posts with the label synchronization context

Can tasks always run in parallel in ASP.Net WebAPI applications?

So this is the first post in the blog and the topic is interesting. A couple days ago, I did a code review for one of our developers, where I made a comment regarding how tasks are scheduled in ASP.Net applications (not ASP.Net Core). I was saying in the code review that no multiple tasks can run in parallel because of the special AspNetSynchronizationContext . Today I was asked the same question by another developer and later figured out I was not 100% correct. So I decided to spend sometime digging a bit deeper into the magic synchronization context and post what I have found. So the source code of the synchronization context could be found here . For those who are not familiar with synchronization context, I would recommend you read this stackoverflow post before continue reading the rest of the content. To make some tests, I wrote a very simple synchronization context class which schedules tasks using the same way as how AspNetSynchronizationContext schedules tasks: So sim...