ASP Getting Started tutorial-preventing or allowing changes to application variable values

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.