Reputation: 407
I have an ASP.WEB Web Api controller that needs to fire and forget some slow code. What would be a good way to do that? That is I want the controller to return an HTML response to the browser, while the slow code keeps running somewhere.
Is it a good idea to grab a worker thread from the tread pool and pass in a complex object created by the controller? Or do I need to write a separate windows service to do the work?
Upvotes: 0
Views: 1124
Reputation: 540
Your solution depends on the specifics or your situation and your workload. You can certainly start of a new task Factory.StartNew when you receive a request. There is nothing wrong with this technically. Things you should think about though:
Upvotes: 2