Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Application_OnStart event (http://www.velocityreviews.com/forums/t77706-application_onstart-event.html)

Marek 05-09-2004 04:32 AM

Application_OnStart event
 
Hi,

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

Marek



Alvin Bruney [MVP] 05-09-2004 05:59 PM

Re: Application_OnStart event
 
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" <marek.stachowicz@sbcglobal.net> wrote in message
news:wvinc.550$gM4.75@newssvr32.news.prodigy.com.. .
> Hi,
>
> Is Application_OnStart event hadler guaranteed to finish its execution
> before another HttpApplication object is brought into life?
>
> Marek
>
>






Marek 05-09-2004 06:50 PM

Re: Application_OnStart event
 
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:ebl6i9eNEHA.1388@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" <marek.stachowicz@sbcglobal.net> wrote in message
> news:wvinc.550$gM4.75@newssvr32.news.prodigy.com.. .
> > Hi,
> >
> > Is Application_OnStart event hadler guaranteed to finish its execution
> > before another HttpApplication object is brought into life?
> >
> > Marek
> >
> >

>
>
>
>




Alvin Bruney [MVP] 05-09-2004 11:58 PM

Re: Application_OnStart event
 
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" <marek.stachowicz@sbcglobal.net> wrote in message
news:V3vnc.619$%B1.357@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:ebl6i9eNEHA.1388@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" <marek.stachowicz@sbcglobal.net> wrote in message
>> news:wvinc.550$gM4.75@newssvr32.news.prodigy.com.. .
>> > Hi,
>> >
>> > Is Application_OnStart event hadler guaranteed to finish its execution
>> > before another HttpApplication object is brought into life?
>> >
>> > Marek
>> >
>> >

>>
>>
>>
>>

>
>




Marek 05-10-2004 01:09 AM

Re: Application_OnStart event
 
Thank you. Where could I read more about it?

"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:usSsQGiNEHA.1644@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" <marek.stachowicz@sbcglobal.net> wrote in message
> news:V3vnc.619$%B1.357@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:ebl6i9eNEHA.1388@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" <marek.stachowicz@sbcglobal.net> wrote in message
> >> news:wvinc.550$gM4.75@newssvr32.news.prodigy.com.. .
> >> > Hi,
> >> >
> >> > Is Application_OnStart event hadler guaranteed to finish its

execution
> >> > before another HttpApplication object is brought into life?
> >> >
> >> > Marek
> >> >
> >> >
> >>
> >>
> >>
> >>

> >
> >

>
>




DalePres 05-10-2004 01:51 AM

Re: Application_OnStart event
 
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" <marek.stachowicz@sbcglobal.net> wrote in message
news:V3vnc.619$%B1.357@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:ebl6i9eNEHA.1388@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" <marek.stachowicz@sbcglobal.net> wrote in message
> > news:wvinc.550$gM4.75@newssvr32.news.prodigy.com.. .
> > > Hi,
> > >
> > > Is Application_OnStart event hadler guaranteed to finish its execution
> > > before another HttpApplication object is brought into life?
> > >
> > > Marek
> > >
> > >

> >
> >
> >
> >

>
>




DalePres 05-10-2004 01:59 AM

Re: Application_OnStart event
 
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:usSsQGiNEHA.1644@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" <marek.stachowicz@sbcglobal.net> wrote in message
> news:V3vnc.619$%B1.357@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:ebl6i9eNEHA.1388@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" <marek.stachowicz@sbcglobal.net> wrote in message
> >> news:wvinc.550$gM4.75@newssvr32.news.prodigy.com.. .
> >> > Hi,
> >> >
> >> > Is Application_OnStart event hadler guaranteed to finish its

execution
> >> > before another HttpApplication object is brought into life?
> >> >
> >> > Marek
> >> >
> >> >
> >>
> >>
> >>
> >>

> >
> >

>
>




Alvin Bruney [MVP] 05-10-2004 01:42 PM

Re: Application_OnStart event
 
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" <marek.stachowicz@sbcglobal.net> wrote in message
news:xDAnc.602$_q1.316@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:usSsQGiNEHA.1644@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" <marek.stachowicz@sbcglobal.net> wrote in message
>> news:V3vnc.619$%B1.357@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:ebl6i9eNEHA.1388@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" <marek.stachowicz@sbcglobal.net> wrote in message
>> >> news:wvinc.550$gM4.75@newssvr32.news.prodigy.com.. .
>> >> > Hi,
>> >> >
>> >> > Is Application_OnStart event hadler guaranteed to finish its

> execution
>> >> > before another HttpApplication object is brought into life?
>> >> >
>> >> > Marek
>> >> >
>> >> >
>> >>
>> >>
>> >>
>> >>
>> >
>> >

>>
>>

>
>




Scott Allen 05-11-2004 05:05 AM

Re: Application_OnStart event
 
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" <nospam@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" <marek.stachowicz@sbcglobal.net> wrote in message
>news:V3vnc.619$%B1.357@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:ebl6i9eNEHA.1388@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" <marek.stachowicz@sbcglobal.net> wrote in message
>> > news:wvinc.550$gM4.75@newssvr32.news.prodigy.com.. .
>> > > Hi,
>> > >
>> > > Is Application_OnStart event hadler guaranteed to finish its execution
>> > > before another HttpApplication object is brought into life?
>> > >
>> > > Marek
>> > >
>> > >
>> >
>> >
>> >
>> >

>>
>>

>




All times are GMT. The time now is 07:03 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.