Application.Unlock Method
The Unlock method enables other clients to modify the variables stored in the Application object after it has been locked using the Application.Lock method. If you do not call this method explicitly, the Web server unlocks the Application Object when the .asp file ends or times out.
Unlock(
)
Parameters
This method has no parameters.
Return Values
This method has no return values.
Remarks
The application Lock method is cumulative, meaning that if the same script calls Lock several times, it must also call Unlock the same number of times to fully release the application. If this does not occur, the application lock will be held until the script is finished running.
A lock on the Application object persists for a very short time because the application object is unlocked when the page completes processing or times out.
If one page locks the application object and a second page tries to do the same while the first page still has it locked, the second page will wait for the first to finish, or until the Server.ScriptTimeout limit is reached. If the Server.ScriptTimeout limit is reached, the following ASP error is returned which cannot be captured:
HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services
Active Server Pages, ASP 0113 (0x80004005)
The maximum amount of time for a script to execute was exceeded.
You can change this limit by specifying a new value for the property
Server.ScriptTimeout or by changing the value in the IIS administration tools.
To reduce the possibility of having an ASP page time out, write a COM+ object that uses the COM+ ObjectContext object to update the Application collection, and then call the COM+ object from an ASP page. COM+ objects execute slightly faster than ASP pages. For more information, see Using the COM+ ObjectContext Object to Access the ASP Built-in Objects
Note
A page does not need to lock the application object to edit the application collection. If one page tries to edit the application collection without locking and a second page also tries to edit the collection, no error is sent by IIS and the Application object ends up in an inconsistent state.
Applies To
Example Code
In the following example, the Unlock method releases the locked object so that the next client can increment NumVisits.
<%@ Language="VBScript" %>
<%
Application.Lock
Application("NumVisits") = Application("NumVisits") + 1
Application("datLastVisited") = Now()
Application.Unlock
%>
This application page has been visited
<%= Application("NumVisits") %> times!
Requirements
Client: Requires Windows XP Professional, Windows 2000 Professional, or Windows NT Workstation 4.0.
Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.
Product: IIS