Reputation: 347
I am coding an ASP.NET MVC 3 app. When a user logs in I need to check a remote system and get the latest data for that user from the system. This task will take approx 15 seconds.
The user should be able to enter my app straight after their login (not have to wait for 15s for the remote call!). When the remote call completes the users local information will be updated.
I was thinking of using a thread to do this, creating it after they have logged in and letting it run its course. However, after reading around, I am concerned about recycling etc when working with threads in MVC. I would use an async controller, but I dont need to feedback to the user the state of this background process. Am I right to be concerned about threads, even if they are short-lived?
Upvotes: 6
Views: 1348
Reputation: 82136
"...concerned about recycling..."
"...don't need to feedback to the user the state..."
"...short-lived..."
3 reasons why you should be using ThreadPool.QueueUserWorkItem.
Upvotes: 5
Reputation: 1738
Do not use "threads" in an web app. Let the server handle this by using "async" calls. Otherwise you would have to setup a threadpool and que the slow request.
Upvotes: 0