You can run a long-running task using ThreadPool.QueueUserWorkItem, and it can update the state in the application / session that the user can poll. As you indicated, that has some problems with life. In addition to what you specified, the application can recycle, but perhaps this is normal.
What is the logical area of this operation? Is this a long-term task like a system so that someone / many people need to request progress? Or is it a long-running task on behalf of a specific user? If this is the last, then it is normal, if it is the time of the user session, etc. If this is the first, you need to be more durable. for example, you can save a task request, status, and progress to a database. Thus, when you restart the application, he can simply choose where he is, and it can be easily requested by anyone (the decision point if the task is a system level).
Final consideration of whether you will ever have multiple web roles (web farm / cluster). If it is ever a consideration than a DB or even a separate role / service of a worker, it becomes more appropriate.
Thus, all this comes down to the type of task for which it is necessary, who should control it and what are the requirements for durability. If this is just a custom task, keep it simple, queueuserworkitem and session state.
bryanmac
source share