Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a short-lived background task from MVC

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?

like image 950
matt Avatar asked Sep 10 '12 14:09

matt


1 Answers

"...concerned about recycling..."

"...don't need to feedback to the user the state..."

"...short-lived..."

3 reasons why you should be using ThreadPool.QueueUserWorkItem.

like image 159
James Avatar answered Nov 05 '22 08:11

James