Use thread and create asynchronous processing in your server code

zhaozj2021-02-16  49

Summary: Fortunately for developers is that threads are far more than in ASP in ASP. In this article, the author gazes the thread in the ASP.NET HTTP PIPELINE, and how the thread is not involved in the developer, how is it efficiently managed. This article considers how the CLR thread pool is used by the ASP.NET service request, and the pool is in processing, model, and application mechanisms, covering bad IIS5 and IIS6, and they differ in request processing and thread allocation. Finally, it is discussed when and how to use asynchronous processing in their applications for developers who need to use threads.

In traditional ASPs, developers face thread problems to know what should be done. Because the ASP is based on COM, there is a very detailed and accurate specification about the thread demand of components. The components used by the page are needed to be placed in the apartment thread for maximum efficiency. Conversely, the components in the session and the application state require a convenient environment and can be aggregated in the free thread collection, and they can protect their status to prevent access.

If you view the ASP.NET documentation, you will find that this is so little about thread demand. This means that all thread problems are solved and the ASP.NET developers can rest assured to develop their ASPX pages and NFCs without confusion on concurrency issues? No, most cases are not the case.

In this article, I will explore the details of the thread in the HTTP pipe and how to manage threads in the HTTP pipe without increasing the burden of the developer. At the same time, I will look at how the ASP.NET uses the CLR thread pool processing service request.

Thread in ASP.NET

For a valid service multiple client requests, the web server responds to service requests by using multiple processes or generating multiple threads. ASP.NET does not use exception and use multiple threads in response requests in a process. Based on this status, ASP.NET developers do not need to care about multithreaded environment. The page demand response is always in a thread, and when there is a new requirement, a new page will create a completely different instance. Different instances and model components for applications are always in response to each request. However, it is very important to understand how to use threads to respond to requests.

At the beginning, ASP.NET responds to requests with a CLR thread pool. The pool is in the machine configuration file (Machine.config), the default is set to 25 working threads and 25 I / O threads:

•••••

MaxWorkerthReads = "25"

MaxiothReads = "25" />

(to be continued)

转载请注明原文地址:https://www.9cbs.com/read-26493.html

New Post(0)