Application_Start()

  • Thread starter Thread starter RB
  • Start date Start date
R

RB

Hi!

Is it guaranteed that Application_Start() will only run once per application
start? In other words, what happens if 2 users simultaneousy hit a "fresh"
app? Does ASP.NET know to run only one thread?

Thanks!
RB
 
A usefull link

http://msdn.microsoft.com/architecture/application/default.aspx?pull=/librar
y/en-us/dnnetsec/html/SecNetAP04.asp

You will get an Application_Start for each HttpApplication object

ASP.NET runtime creates as many instances of application class as is need
to process requests simultaneously. For most applications this number is
limited to the number of threads, and would stay in 1-100 range depending
on the hardware, server load, configuration, etc. Application instances are
reused for many requests, and a free list of application instances is kept
during the periods of reduced load. Application instances are utilized in a
thread safe manner, one request at a time. This has important implications:

Users don't need to worry about locking, to access non-static members of
the application class.
Application code can store per-request data in non-static members of the
application class (but not after EndRequest event, as it would keep the
request alive potentially for a long time).
Static members of application class, as of any class, are not thread safe,
and the user code needs to provide appropriate locking around access to
static members.

Andy Mortimer [MS]
Please do not send email directly to this alias. This alias is for
newsgroup purposes only

This posting is provided "AS IS" with no warranties, and confers no rights.
OR if you wish to include a script sample in your post please add "Use of
included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm"
 
The Application_OnStart Method is an Event Handler. As such, it will not
fire more than once, when the first request is received. There is no real
"simultaneous" request, although at the speed with which they are processed
it might seem so. Requests are queued.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Back
Top