I have this ASP MVC call which is aync because of an async call it needs to make. I noticed there are a couple of slow sync calls (e.g. db access). The method needs to have all returned data available in order to proceed.
I thought of wrapping the sync calls with Task.Run and await for all of them.
Does it make sense to wrap the slow sync calls? What if there was only sync calls?
Don't use Task.Run
to parallelize work in the server-side code, unless the number of client requests you expect to serve concurrently is really low. Otherwise, you might speed up the processing of an individual request, but you'll hurt scalability of your web app for when there are many users.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With