. NET ASP Web application Quick Start (2) (reprint)
Source: Internet
Author: User
Application|web| QuickStart Application Lifetime
A asp.net application is created the first time the server is requested, not before that
There are asp.net code in execution. After accepting the first request, a HttpApplication instance
The pool was created and the Application_OnStart event was activated. HttpApplication instance
Process the request and subsequent requests until the last instance exits, and then triggers
Application_OnEnd event.
Note that in each instance, the HttpApplication init and Dispose methods are all tuned
, so that between the Application_OnStart and the Application_OnEnd events will be
Called multiple times. In a asp.net
In application, only these events are shared in all HttpApplication instances.
About multithreading
If we use objects in the application range type, we should be aware that asp.net is
Concurrent processing of requests, thus application objects can be accessed by multiple threads. So
If the code in the following example is accessed by a different client at the same time, it is dangerous,
may not achieve the intended purpose. For comparison convenience, we have listed the use of VB, C # and
Code written in JScript three languages:
To achieve secure threading, we can handle this with the lock and unlock methods
Application object. Take a look at the following generation in VB, C #, and JScript three languages
Code:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.