I have a web api 2 controller, the client requests the controller for some kind of html generations(consists of images, files etc.). As the process needs some time and I don't want the users to wait, I have followed the following approach in the Controller :
...Controller(){
Task.Run(() =>
{
//calling heavy duty method to download files where Task.WaitAll() resides
DownloadAndRename()
});
}
DownloadAndRename(){
//created some child task here and run them in task.waitall()
//Task.WaitAll() here
}
I have created tasks for every file to download, rename and other processes. Then execute them in Task.WaitAll().
When I locally run the application, everything is okay. But when I deploy to my test server, it was throwing following exception:
Message: System.Threading.ThreadAbortException: Thread was being aborted.
P.S. In my pc, I have only one application running in the app pool, whereas in my test server there are 8 in that particular pool.
How can I overcome the exception?
Update 1: I have tried by removing the task.WaitAll and do the implementation without using Task. Still, I get the thread abort error, I think somehow the Task.Run() get timed out.