I have an Index
action in ASP.net MVC controller. This action, calls (among other things) a private action that do a count on a SQL table with large set of rows. Th
Instead of async, use Task.Run:
Task.Run(() => MethodToExecuteInBackground(methodParameters)).ConfigureAwait(false).GetAwaiter();
You will also need to remove the async modifier from your controller Index method.
Now your controller method will return immediately while MethodToExecuteInBackground
goes off and does some work in the background.
Be aware that this will tie up a thread-pool thread until MethodToExecuteInBackground
finishes.