Best way to run a background task in ASP.Net web app and also get feedback?

前端 未结 4 2014
悲&欢浪女
悲&欢浪女 2020-12-16 07:05

I am thinking on the following approach but not sure if its the best way out:

step1 (server side): A TaskMangaer class creates a new thread and start a task.
ste

4条回答
  •  不知归路
    2020-12-16 07:26

    One approach for doing this is to use application state. When you spawn a worker thread, pass it a request ID that you generate, and return this to the client. The client will then pass that request ID back to the server in its AJAX calls. The server will then fetch the status using the request ID from application state. (The worker thread would be updating the application state based on its status).

提交回复
热议问题