When to use System.Threading.ThreadPool and when is one of many custom thread pools?

I am working on creating an async handler for ASP.NET that will execute a slow stored procedure. I think I understand that in order to get extra throughput when mixed loading of slow and fast pages, the slow page should run in a thread pool separate from the one that ASP.NET uses, otherwise the async pattern will double the number (correct me , if I am wrong).

So, I found System.Threading.ThreadPool - it looks like it should do the trick, but ...

Various online tutorials, such as the one that uses this user pool , one in John Skeet MiscUtils , and the custom thread pool that this tutorial about asynchronous templates reference.

System.Threading.ThreadPool exists since 1.1 - why do people usually feel the need to write completely new? Shouldn't I use System.Threading.ThreadPool ?

I start ranking when it comes to streaming processing, so easily sculpt undefined in jargon.

UPDATE The stored procedure that must be executed will not necessarily be MS-SQL and may not necessarily be able to use the built-in async method, such as BeginExecuteNonQuery() .

+7
source share
1 answer

Here is what I found on this topic. Why you should not use ThreadPool in ASP.NET http://madskristensen.net/post/Done28099t-use-the-ThreadPool-in-ASPNET.aspx . It's quite old, but I don’t think it has changed so much. Or correct me if I am wrong.

Using System.Threading.ThreadPool or a custom delegate and calling it BeginInvoke offers a quick way to disable workflows for your application. But, unfortunately, they damaged the overall performance of your application, as they consume threads from the same pool that ASP.NET uses to process HTTP requests.

Using custom threads using the System.Threading.Thread class should solve the problem, since the created threads are not part of your application pool.

+3
source

All Articles