When Asp.net terminates background threads?

前端 未结 3 1494
一向
一向 2021-01-27 10:42

I was working on a project and there is bulk e-mail sending part of it and when user clicks on the button, he/she gets the \"Thanks the e-mails have been sent\" immediately as a

3条回答
  •  梦毁少年i
    2021-01-27 11:27

    Using the ThreadPool for long-running tasks will negatively influence the performance of your application (because ASP.NET also uses the ThreadPool to handle incoming requests).

    Creating threads manually for each task can also become a problem if too much threads are created.

    One technique I've used in the past, is to create a custom ThreadPool when starting the application, and enqueuing tasks on that ThreadPool. A simple custom ThreadPool could consist of a single Thread and a Queue of tasks.

提交回复
热议问题