Application lock state during Application start

A

APA

In the Application_Start event I load several static variables with data from the database that are critical to the execution of the application.
My question is that during app start if a second request comes in before app start is complete does it wait for app start to complete or does it go
straight to BeginRequest? It appears in some cases that begin request is being called before app start is finished. We know this because we test for
this static variable being null in BeginRequest. So, do I need to do Application.Lock() and Application.UnLock() in Application_OnStart to prevent
any requests from being processed until app start is complete? I would have thought that the default behavior would be to lock the application until
it is started.

Thx.
 
G

Guest

APA,
I doubt that employing the Application.Lock / Unlock methods would
accomplish your objective, as all they do is prevent modification of
Application objects by another thread until the Unlock method has completed.
Probably a safer and more reliable operation would be to figure out a way to
sleep a ver early Request until it can definitively gain access to non-null
static variables that you were setting in your Application_Start event.
I haven't got much background in this area and would defer to others who
have better ideas, but in the worst case scenario, you could abort a Request
that is not able to get access to the static variables by throwing an
appropriate exception, causing the user to have to try again.
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,991
Messages
2,570,217
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top