
Lock | 285
Application
Class
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Parameter
Index
A variable of type Integer that specifies the index of the key to be retrieved
from the Application collection.
Example
The example removes all values from the Application collection in order to start
from a known state. Next, it writes a single value to the Application collection.
Finally, it saves the key from the first element (index 0) retrieved by a call to
GetKey into the Message control.
Sub Page_Load( )
Application.RemoveAll( )
Application("GetKeyTest") = "Got it!"
Message.Text = "Key of Application(0) = " & _
Application.GetKey(0) & _
"<br/>(Should be GetKeyTest)"
End Sub
Notes
If Index is less than 0 or greater than Application.Count – 1, an Argu-
mentOutOfRangeException exception will be thrown.
Lock
Application.Lock
Locks access to an Application collection to facilitate access synchronization.
Parameters
None.
Example
The example locks the application, sets an application page load counter vari-
able, unlocks the application, and displays the value:
Sub Page_Load( )
Application.Lock( )
Application("Counter") = Application("Counter") + 1
Application.UnLock( )
Message.Text = "Counter = " & Application("Counter")
End Sub
Notes
In the example, note that we Lock the application, perform any operations that
modify values within the Application