Possible ways to do async over sync
Solution 1:
wonder if any of these is a good idea.
Nope.
Every attempt at async-over-sync on ASP.NET causes additional memory overhead. And some of them (Task.Run
and Task.Yield
) also cause an additional thread switch.
The whole point of asynchronous code is to free up a thread, but if you have an unavoidable blocking call, then the thread can't be freed, by definition. As Panagiotis pointed out, you might be able to replace the blocking call with an asynchronous one, but if not, then async-over-sync won't help you.