I’ve tried to figure out whether using ThreadPools in an ASP.NET site is good or not. There’s a lot of discussion about this but difficult to find an authorative source.
I’m building a site where the user fills out a form and presses the send button, this triggers a mail to be sent. My problem is that my mail vendor’s API is quite slow (100ms to 12s) and this is not good for responsiveness of the app.
Is this a good idea?:
ThreadPool.QueueUserWorkItem(e =>
EmailFactory.BuildBuyerEmailValidationEmail(client).Send()
);
The form is used about 100-200 times a day.
I’d like to avoid creating a queue as this would increase application complexity.
This looks totally fine to me. The thread pool contains 250 threads per processor, so even if this form would be submitted 50 times a minute, it would not be any problem, because then only about ten threads would be working in parallel