The Application object has two methods: Lock and Unlock methods. Use these two methods to ensure that multiple users cannot change a property at the same time.
1, Application Method
The Lock method prevents other customers from modifying the Application object's variables. The syntax format is as follows:
Application.Lock
2. The Unlock method using the Application object allows other clients to modify the variables stored in the object after using lock to lock the Application object. If the method is not explicitly invoked, the WEB server unlocks the Application object after the. asp file ends or times out. The syntax format is as follows:
Application.Unlock
3, example of the above section 2
<% @ language="vbscript" %>
<title>Application 数组应用示例 </title><body>
<%
dim poem() '创建一个数组
Redim poem(3) '为数组分配存储空间
poem(0)="姓名:含笑" '为数组进行初始化
poem(1)="性别:女"
poem(2)="E-mail:www@163.com"
Application.Lock '锁定Application 对象
Application("StoredArray")=poem '将数组存储到 Application 对象中
Application.Unlock '解除对Application 对象的锁定
Server.Transfer"3.asp" '调用另外一个.asp文件
%>
4, Code annotation:
When we want to store the array poem in the Application object, we first lock the Applicatoin object with the lock method of the Application object and prevent other clients from changing the Application object, when the array is stored in the application Object, the Application object's Unlock method is used to unblock the application object, allowing other clients to change the Application object. If this method is not explicitly invoked, the WEB server unlocks the Application object after the. asp file ends or times out.
See the full set of ASP Getting started tutorials