473,406 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Application_OnStart event

Hi,

Is Application_OnStart event hadler guaranteed to finish its execution
before another HttpApplication object is brought into life?

Marek
Nov 18 '05 #1
8 1447
No such guarantee is made. I think there is some confusion in the question
as well.

The application_onstart event handler is an event which fires when a request
is paired with an httpapplication instance. The guarantee is only that this
request will be associated with this one httpapplication instance, that is,
sequential processing thru the http pipeline until the request is serviced
fully by that specific httpapplication instance. Each request/instance pair
is handled on any available thread from the threadpool. The pairing process
is not
sequential.

The responsibility of pairing falls to the httpruntime object. The
httpruntime object can handle many simultaneous concurrent
requests - limited only by the available threads in the threadpool
responsible for servicing requests. In this case, each request gets paired
with an httpapplication instance. If the httpruntime could only respond to
one request at a time, this would create a bottleneck under load. Once a
request has been received, there is an implicit guarantee that the request
can be associated with only one httpapplciation object.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Marek" <ma**************@sbcglobal.net> wrote in message
news:wv**************@newssvr32.news.prodigy.com.. .
Hi,

Is Application_OnStart event hadler guaranteed to finish its execution
before another HttpApplication object is brought into life?

Marek



Nov 18 '05 #2
Hi Alvin,

Thank you for your explanation. Still, I don't understand something.
Application_OnStart event is raised only ONCE on the first instance of
HttpApplication. Right?
I saw many examples of code where they perform some global initialization in
this handler
(such as reading config files, remote configuration to name a few). However,
I didn't see any prevention against
other HttpApplication instaces access the results of configuration BEFORE
Application_OnStart event
handler ends its execution. So I came to the question I asked. Could you
explain where I'm making
a mistake?

Marek

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:eb**************@TK2MSFTNGP09.phx.gbl...
No such guarantee is made. I think there is some confusion in the question
as well.

The application_onstart event handler is an event which fires when a request is paired with an httpapplication instance. The guarantee is only that this request will be associated with this one httpapplication instance, that is, sequential processing thru the http pipeline until the request is serviced
fully by that specific httpapplication instance. Each request/instance pair is handled on any available thread from the threadpool. The pairing process is not
sequential.

The responsibility of pairing falls to the httpruntime object. The
httpruntime object can handle many simultaneous concurrent
requests - limited only by the available threads in the threadpool
responsible for servicing requests. In this case, each request gets paired
with an httpapplication instance. If the httpruntime could only respond to
one request at a time, this would create a bottleneck under load. Once a
request has been received, there is an implicit guarantee that the request
can be associated with only one httpapplciation object.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Marek" <ma**************@sbcglobal.net> wrote in message
news:wv**************@newssvr32.news.prodigy.com.. .
Hi,

Is Application_OnStart event hadler guaranteed to finish its execution
before another HttpApplication object is brought into life?

Marek


Nov 18 '05 #3
The framework guarantees that, regardless of concurrent requests, the
application object will be initialized only once per application domain.
This happens when the first request is received. If two requests are
received at the same time, the runtime uses a spin-lock to force one request
to wait while the other is serviced guaranteeing threadsafety.

Now, once that initialization has occurred, its an open field where thread
access/concurrency is concerned so care must be taken for objects with
global scope in the application object. Good question. I had to think about
this for a while.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Marek" <ma**************@sbcglobal.net> wrote in message
news:V3***************@newssvr32.news.prodigy.com. ..
Hi Alvin,

Thank you for your explanation. Still, I don't understand something.
Application_OnStart event is raised only ONCE on the first instance of
HttpApplication. Right?
I saw many examples of code where they perform some global initialization
in
this handler
(such as reading config files, remote configuration to name a few).
However,
I didn't see any prevention against
other HttpApplication instaces access the results of configuration BEFORE
Application_OnStart event
handler ends its execution. So I came to the question I asked. Could you
explain where I'm making
a mistake?

Marek

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:eb**************@TK2MSFTNGP09.phx.gbl...
No such guarantee is made. I think there is some confusion in the
question
as well.

The application_onstart event handler is an event which fires when a

request
is paired with an httpapplication instance. The guarantee is only that

this
request will be associated with this one httpapplication instance, that

is,
sequential processing thru the http pipeline until the request is
serviced
fully by that specific httpapplication instance. Each request/instance

pair
is handled on any available thread from the threadpool. The pairing

process
is not
sequential.

The responsibility of pairing falls to the httpruntime object. The
httpruntime object can handle many simultaneous concurrent
requests - limited only by the available threads in the threadpool
responsible for servicing requests. In this case, each request gets
paired
with an httpapplication instance. If the httpruntime could only respond
to
one request at a time, this would create a bottleneck under load. Once a
request has been received, there is an implicit guarantee that the
request
can be associated with only one httpapplciation object.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Marek" <ma**************@sbcglobal.net> wrote in message
news:wv**************@newssvr32.news.prodigy.com.. .
> Hi,
>
> Is Application_OnStart event hadler guaranteed to finish its execution
> before another HttpApplication object is brought into life?
>
> Marek
>
>



Nov 18 '05 #4
Thank you. Where could I read more about it?

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:us**************@TK2MSFTNGP09.phx.gbl...
The framework guarantees that, regardless of concurrent requests, the
application object will be initialized only once per application domain.
This happens when the first request is received. If two requests are
received at the same time, the runtime uses a spin-lock to force one request to wait while the other is serviced guaranteeing threadsafety.

Now, once that initialization has occurred, its an open field where thread
access/concurrency is concerned so care must be taken for objects with
global scope in the application object. Good question. I had to think about this for a while.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Marek" <ma**************@sbcglobal.net> wrote in message
news:V3***************@newssvr32.news.prodigy.com. ..
Hi Alvin,

Thank you for your explanation. Still, I don't understand something.
Application_OnStart event is raised only ONCE on the first instance of
HttpApplication. Right?
I saw many examples of code where they perform some global initialization in
this handler
(such as reading config files, remote configuration to name a few).
However,
I didn't see any prevention against
other HttpApplication instaces access the results of configuration BEFORE Application_OnStart event
handler ends its execution. So I came to the question I asked. Could you
explain where I'm making
a mistake?

Marek

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:eb**************@TK2MSFTNGP09.phx.gbl...
No such guarantee is made. I think there is some confusion in the
question
as well.

The application_onstart event handler is an event which fires when a

request
is paired with an httpapplication instance. The guarantee is only that

this
request will be associated with this one httpapplication instance, that

is,
sequential processing thru the http pipeline until the request is
serviced
fully by that specific httpapplication instance. Each request/instance

pair
is handled on any available thread from the threadpool. The pairing

process
is not
sequential.

The responsibility of pairing falls to the httpruntime object. The
httpruntime object can handle many simultaneous concurrent
requests - limited only by the available threads in the threadpool
responsible for servicing requests. In this case, each request gets
paired
with an httpapplication instance. If the httpruntime could only respond
to
one request at a time, this would create a bottleneck under load. Once a request has been received, there is an implicit guarantee that the
request
can be associated with only one httpapplciation object.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Marek" <ma**************@sbcglobal.net> wrote in message
news:wv**************@newssvr32.news.prodigy.com.. .
> Hi,
>
> Is Application_OnStart event hadler guaranteed to finish its execution > before another HttpApplication object is brought into life?
>
> Marek
>
>



Nov 18 '05 #5
The solution to the problem is to lock the application object early in the
code of your Application_OnStart with a call to Application.Lock(). This
will make sure that any other calls are blocked until you complete your
initialization.

Dale

"Marek" <ma**************@sbcglobal.net> wrote in message
news:V3***************@newssvr32.news.prodigy.com. ..
Hi Alvin,

Thank you for your explanation. Still, I don't understand something.
Application_OnStart event is raised only ONCE on the first instance of
HttpApplication. Right?
I saw many examples of code where they perform some global initialization in this handler
(such as reading config files, remote configuration to name a few). However, I didn't see any prevention against
other HttpApplication instaces access the results of configuration BEFORE
Application_OnStart event
handler ends its execution. So I came to the question I asked. Could you
explain where I'm making
a mistake?

Marek

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:eb**************@TK2MSFTNGP09.phx.gbl...
No such guarantee is made. I think there is some confusion in the question as well.

The application_onstart event handler is an event which fires when a

request
is paired with an httpapplication instance. The guarantee is only that

this
request will be associated with this one httpapplication instance, that

is,
sequential processing thru the http pipeline until the request is serviced fully by that specific httpapplication instance. Each request/instance

pair
is handled on any available thread from the threadpool. The pairing

process
is not
sequential.

The responsibility of pairing falls to the httpruntime object. The
httpruntime object can handle many simultaneous concurrent
requests - limited only by the available threads in the threadpool
responsible for servicing requests. In this case, each request gets paired with an httpapplication instance. If the httpruntime could only respond to one request at a time, this would create a bottleneck under load. Once a
request has been received, there is an implicit guarantee that the request can be associated with only one httpapplciation object.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Marek" <ma**************@sbcglobal.net> wrote in message
news:wv**************@newssvr32.news.prodigy.com.. .
Hi,

Is Application_OnStart event hadler guaranteed to finish its execution
before another HttpApplication object is brought into life?

Marek



Nov 18 '05 #6
Application.Init will be called for each instance of the application which
approximately equals the maximum number of simultaneous requests since an
application instance handles one request at a time. Application_OnStart
will be called only once when the first instance of the application is
called.

Dale

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:us**************@TK2MSFTNGP09.phx.gbl...
The framework guarantees that, regardless of concurrent requests, the
application object will be initialized only once per application domain.
This happens when the first request is received. If two requests are
received at the same time, the runtime uses a spin-lock to force one request to wait while the other is serviced guaranteeing threadsafety.

Now, once that initialization has occurred, its an open field where thread
access/concurrency is concerned so care must be taken for objects with
global scope in the application object. Good question. I had to think about this for a while.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Marek" <ma**************@sbcglobal.net> wrote in message
news:V3***************@newssvr32.news.prodigy.com. ..
Hi Alvin,

Thank you for your explanation. Still, I don't understand something.
Application_OnStart event is raised only ONCE on the first instance of
HttpApplication. Right?
I saw many examples of code where they perform some global initialization in
this handler
(such as reading config files, remote configuration to name a few).
However,
I didn't see any prevention against
other HttpApplication instaces access the results of configuration BEFORE Application_OnStart event
handler ends its execution. So I came to the question I asked. Could you
explain where I'm making
a mistake?

Marek

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:eb**************@TK2MSFTNGP09.phx.gbl...
No such guarantee is made. I think there is some confusion in the
question
as well.

The application_onstart event handler is an event which fires when a

request
is paired with an httpapplication instance. The guarantee is only that

this
request will be associated with this one httpapplication instance, that

is,
sequential processing thru the http pipeline until the request is
serviced
fully by that specific httpapplication instance. Each request/instance

pair
is handled on any available thread from the threadpool. The pairing

process
is not
sequential.

The responsibility of pairing falls to the httpruntime object. The
httpruntime object can handle many simultaneous concurrent
requests - limited only by the available threads in the threadpool
responsible for servicing requests. In this case, each request gets
paired
with an httpapplication instance. If the httpruntime could only respond
to
one request at a time, this would create a bottleneck under load. Once a request has been received, there is an implicit guarantee that the
request
can be associated with only one httpapplciation object.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Marek" <ma**************@sbcglobal.net> wrote in message
news:wv**************@newssvr32.news.prodigy.com.. .
> Hi,
>
> Is Application_OnStart event hadler guaranteed to finish its execution > before another HttpApplication object is brought into life?
>
> Marek
>
>



Nov 18 '05 #7
Dino Esposito's book is about as good as it gets on ASP.NET. This book is
not about examples and snippets of code, it's about theory and how things
work underneath the hood.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Marek" <ma**************@sbcglobal.net> wrote in message
news:xD***************@newssvr16.news.prodigy.com. ..
Thank you. Where could I read more about it?

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:us**************@TK2MSFTNGP09.phx.gbl...
The framework guarantees that, regardless of concurrent requests, the
application object will be initialized only once per application domain.
This happens when the first request is received. If two requests are
received at the same time, the runtime uses a spin-lock to force one

request
to wait while the other is serviced guaranteeing threadsafety.

Now, once that initialization has occurred, its an open field where
thread
access/concurrency is concerned so care must be taken for objects with
global scope in the application object. Good question. I had to think

about
this for a while.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Marek" <ma**************@sbcglobal.net> wrote in message
news:V3***************@newssvr32.news.prodigy.com. ..
> Hi Alvin,
>
> Thank you for your explanation. Still, I don't understand something.
> Application_OnStart event is raised only ONCE on the first instance of
> HttpApplication. Right?
> I saw many examples of code where they perform some global initialization > in
> this handler
> (such as reading config files, remote configuration to name a few).
> However,
> I didn't see any prevention against
> other HttpApplication instaces access the results of configuration BEFORE > Application_OnStart event
> handler ends its execution. So I came to the question I asked. Could
> you
> explain where I'm making
> a mistake?
>
> Marek
>
> "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
> news:eb**************@TK2MSFTNGP09.phx.gbl...
>> No such guarantee is made. I think there is some confusion in the
>> question
>> as well.
>>
>> The application_onstart event handler is an event which fires when a
> request
>> is paired with an httpapplication instance. The guarantee is only that
> this
>> request will be associated with this one httpapplication instance,
>> that
> is,
>> sequential processing thru the http pipeline until the request is
>> serviced
>> fully by that specific httpapplication instance. Each request/instance
> pair
>> is handled on any available thread from the threadpool. The pairing
> process
>> is not
>> sequential.
>>
>> The responsibility of pairing falls to the httpruntime object. The
>> httpruntime object can handle many simultaneous concurrent
>> requests - limited only by the available threads in the threadpool
>> responsible for servicing requests. In this case, each request gets
>> paired
>> with an httpapplication instance. If the httpruntime could only
>> respond
>> to
>> one request at a time, this would create a bottleneck under load. Once a >> request has been received, there is an implicit guarantee that the
>> request
>> can be associated with only one httpapplciation object.
>>
>>
>>
>> --
>> Regards,
>> Alvin Bruney
>> [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
>> Got tidbits? Get it here... http://tinyurl.com/27cok
>> "Marek" <ma**************@sbcglobal.net> wrote in message
>> news:wv**************@newssvr32.news.prodigy.com.. .
>> > Hi,
>> >
>> > Is Application_OnStart event hadler guaranteed to finish its execution >> > before another HttpApplication object is brought into life?
>> >
>> > Marek
>> >
>> >
>>
>>
>>
>>
>
>



Nov 18 '05 #8
This locks the Application state object, which doesn't block any other
requests unless they are trying to lock the Application object also.

--
Scott
http://www.OdeToCode.com

On Sun, 9 May 2004 20:51:03 -0500, "DalePres" <no****@nomail.com>
wrote:
The solution to the problem is to lock the application object early in the
code of your Application_OnStart with a call to Application.Lock(). This
will make sure that any other calls are blocked until you complete your
initialization.

Dale

"Marek" <ma**************@sbcglobal.net> wrote in message
news:V3***************@newssvr32.news.prodigy.com ...
Hi Alvin,

Thank you for your explanation. Still, I don't understand something.
Application_OnStart event is raised only ONCE on the first instance of
HttpApplication. Right?
I saw many examples of code where they perform some global initialization

in
this handler
(such as reading config files, remote configuration to name a few).

However,
I didn't see any prevention against
other HttpApplication instaces access the results of configuration BEFORE
Application_OnStart event
handler ends its execution. So I came to the question I asked. Could you
explain where I'm making
a mistake?

Marek

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:eb**************@TK2MSFTNGP09.phx.gbl...
> No such guarantee is made. I think there is some confusion in thequestion > as well.
>
> The application_onstart event handler is an event which fires when a

request
> is paired with an httpapplication instance. The guarantee is only that

this
> request will be associated with this one httpapplication instance, that

is,
> sequential processing thru the http pipeline until the request isserviced > fully by that specific httpapplication instance. Each request/instance

pair
> is handled on any available thread from the threadpool. The pairing

process
> is not
> sequential.
>
> The responsibility of pairing falls to the httpruntime object. The
> httpruntime object can handle many simultaneous concurrent
> requests - limited only by the available threads in the threadpool
> responsible for servicing requests. In this case, each request getspaired > with an httpapplication instance. If the httpruntime could only respondto > one request at a time, this would create a bottleneck under load. Once a
> request has been received, there is an implicit guarantee that therequest > can be associated with only one httpapplciation object.
>
>
>
> --
> Regards,
> Alvin Bruney
> [ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
> Got tidbits? Get it here... http://tinyurl.com/27cok
> "Marek" <ma**************@sbcglobal.net> wrote in message
> news:wv**************@newssvr32.news.prodigy.com.. .
> > Hi,
> >
> > Is Application_OnStart event hadler guaranteed to finish its execution
> > before another HttpApplication object is brought into life?
> >
> > Marek
> >
> >
>
>
>
>



Nov 18 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mark Hoagland | last post by:
I've got a scenario with a web application where I must access the virtual directory being accessed from within the Application_OnStart event handler. Specifically, I have a series of IIS virtual...
1
by: fruddy | last post by:
Hi everyone, Just wanted to ask about Application_OnStart in the global.asa. Now if I request one page from a particular site when I first go to that site say mysite.com/default.asp that triggers...
4
by: David Logan | last post by:
Hello, I working on a project where we will be hosting several websites on the same server. These websites are built of a similar template and I want to use the URL as a key to get settings...
3
by: Bren | last post by:
Hi All In the global.asa file, when does the Application_OnStart event trigger? Is it:- 1. When the webserver starts or 2. When the website is first accessed AFTER the webserver has started. ...
0
by: Simon | last post by:
Hi, I am a little confused between Application_Start() and Application_OnStart(). Also, Session_Start() and Session_OnStart(). When exactly do these events trigger out? Thanks
3
by: F C | last post by:
Hello, I would like to find the virtual directory name from within Application_onStart in global.asa. I am in ASP, not ASPX. I have no server.AppPath. Thanks for your help. François.
19
by: Shiv Kumar | last post by:
I see that the Application_OnStart event is fired only once for a certain application. I'm interested in creating a "global" object (an object that will be available to all requests for the...
5
by: Mike Logan | last post by:
We are creating an HTTP Module to add code to the Application On Start of an applicaton. However, there is no HTTPApplication.OnStart event to attach to. Does anyone know how to attach to this...
1
by: archana | last post by:
Hi all, I am new to asp.net. I am having one confusion regarding application_onstart event. Let me explain what i am doing:- Say i have one xml file whose setting i am reading on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.