ThreadPool.QueueUserWorkItem uses ASP.Net

前端 未结 3 2078
孤街浪徒
孤街浪徒 2021-01-07 01:12

In Asp.Net for creating a huge pdf report iam using \"ThreadPool.QueueUserWorkItem\", My requirement is report has to be created asynchronously , and i do not want to wait f

3条回答
  •  余生分开走
    2021-01-07 01:33

    The thread pool will manage the number of active threads as needed. Once a thread is done with a task it continues on the next queued task. Using the thread pool is normally a good way to handle background processing.

    When running in an ASP.NET application there are a couple of things to be aware of:

    • ASP.NET applications can be recycled for various reasons. When this happens all queued work items are lost.
    • There is no simple way to signal back to the client web browser that the operation completed.

    A better approach in your case might be to have a WCF service with a REST/JSON binding that is called by AJAX code on the client web page for doing the heavy work. This would give you the possibility to report process and results back to the user.

提交回复
热议问题