asp.netthreadpooltask-parallel-libraryasync-awaitihttpasynchandler

Using Task or async/await in IHttpAsyncHandler


Since the very begining of writing ASP.NET applications when I wanted to add a threading there are 3 simple ways I can accomplish threading within my ASP.NET application :

The first two methods offer a quick way to fire off worker threads for your application. But unfortunately, they hurt the overall performance of your application since they consume threads from the same pool used by ASP.NET to handle HTTP requests.

Then I wanted to use a new Task or async/await to write IHttpAsyncHandler. One example you can find is what Drew Marsh explains here : https://stackoverflow.com/a/6389323/261950

My guess is that using Task or async/await still consume the thread from the ASP.NET thread pool and I don't want for the obvious reason.

Could you please tell me if I can use Task (async/await) on the background thread like with System.Threading.Thread class and not from thread pool ?

Thanks in advance for your help.

Thomas


Solution

  • I've been looking for information through internet for a couple of days. Let me sum up what I found until now :

    ASP.NET ThreadPool facts

    But as far as I know you can't chose whetever you want to use a IOCP thread, and making correct implementation of the threadPool is not worth the effort. I doubt someone does a better one that already exists.

    When you should start thinking about implementing asynchronous execution ?

    Should I create new Threads ?

    And the TPL ?

    References