Running a short background task from MVC

I am encoding an ASP.NET MVC 3 application. When a user logs in, I need to check the remote system and get the latest data for this user from the system. This task will take about 15 seconds.

The user should be able to log into my application immediately after logging in (no need to wait 15 seconds for a remote call!). When the remote call ends, user information will be updated.

I was thinking about using a thread to do this, creating it after they logged in and let it run its course. However, after reading, I am worried about disposal, etc. When working with threads in MVC. I would use an asynchronous controller, but I do not need to pay attention to the status of this background process. Am I right to worry about threads, even if they are short-lived?

+6
source share
2 answers

"... concerned about recycling ..."

"... no need to pay attention to the state of the user ..."

"... short-lived ..."

3 reasons why you should use ThreadPool.QueueUserWorkItem .

+5
source

Do not use streams in a web application. Let the server handle this using asynchronous calls. Otherwise, you will have to configure threadpool and que a slow request.

0
source

Source: https://habr.com/ru/post/925035/


All Articles