asp.net - using Threadpool.QueueWorkItem in Asnychronous Handler -


For an asynchronous handler it starts the new thread using MSDN ThreadPool.QueueUserWorkItem.

I thought that the thread is taken from the ASP.net thread pool and the purpose of using the asynchronous handler should not be to use Threadpool. QUUserverctrite as a dashed.

What's wrong with the example?

Some things are wrong in your claim:

  • Code> ThreadPool.QueueUserWorkItem , you do not start a new thread. This is the issue of being thradpold in the first place. You are reusing a thread from a pool.
  • You mean that the example was specifically targeting ASP.NET, when it is not. This is showing you how to use Threadpool, to stop background tasks (which are expensive) without manually creating new sources. When and when to use ThreadPool, it is still yours, it is still yours.
  • Using Threadpool to run an asynchronous task "does not defeat the purpose of using an asynchronous handler"
  • Manually firing another thread is not giving you You do not block the user experience while working and you use the asynchronous handler for various reasons to use the machine's resources. If you are working on a simple background, then using ThreadPool is nothing more than that. If for some reason you are worried that you will somehow be "tired" in the thread of IIS, in order to fulfill the incoming requests, I think that you dismiss that concern before annoying you with your asynchronous workers Your machine will be brought with traffic on your knees.
  • Just to be clear, if you are not running an ASP.NET application, then your own process will be:

    When a managed application is executed, runtime threads Which provides access to the code for the first time. This pool is connected with the physical process where the application is running, an important statement when you are using the functionality available in .NET infrastructure to run many applications (application domain names) within the same process. If this is the case, then a bad application can affect everyone else in the same process because they all use the same pool.

    You can use the thread pool or information about it can be retrieved in the Threadpool class System.Threading namespace If you take a look at this class, you will see that all the members are stationary And there are no public makers. It makes sense, because per process is only a pool and we can not make a new one. The objective of this limitation is to centralize all asynchronous programming in the same pool, so that we do not have a third-party component which creates a parallel pool which we can not manage and whose threads are insulting our performance.

    No, the example is not wrong The example is absolutely fine and it is highlighted exactly what it was to do.

Comments