Doubts about application variables

  • Thread starter Thread starter Chris Leffer
  • Start date Start date
C

Chris Leffer

Hi.

Reading some Microsoft materials about asp.net I came into two doubts.

The following sentence is found on the topic "Application State" in the
NET Framework documentation:

"Calling Lock on the Application object causes ASP.NET to block attempts
by code running on other worker threads to access anything in
application state"

So, if I use Lock this way:

Application.Lock()
Application("myVar") = 10
Application.UnLock()

All the other application variables on my system are blocked too?


My second doubt relates to a sentence found on one of the Microsoft
asp.net official courses:
The topic about application variables says:

"The Application object is destroyed when all users have exited the Web
application and the Web
application is then unloaded."

To test this, I created some application variables in an asp.net
application, load them and then exited the application. When I run the
application again, the application variables are still there with the
more recent values. It seems to me that application variables are only
destroyed when their host is destroyed, in this case, the IIS process.
Can anyone help me to understand the above sentence?

Regards,

Chris Leffer
 
When you call Application.Lock and Application.Unlock, they are applied
only to the application variable in the current context.

The application state/variables are destroyed when the web application
is specifically unloaded..means stopping the IIS or web
application..Even if there are no active users accessing the web server,
the application state/variables are preserved until the web application
is stopped...that is how we generally keep track of the number of
visitors to a particualr web site.

Hope this helps...

--Rao
 
Back
Top