This documentation is archived and is not being maintained.
HttpApplicationState.Lock Method
.NET Framework 1.1
Locks access to an HttpApplicationState variable to facilitate access synchronization.
[Visual Basic] Public Sub Lock() [C#] public void Lock(); [C++] public: void Lock(); [JScript] public function Lock();
Example
The following example uses Lock() and UnLock() to prevent other sessions from changing the value of two application variables until after the local session has changed them.
[Visual Basic] Application.Lock() Application("MyCode") = 21 Application("MyCount") = Convert.ToInt32(Application("MyCount")) + 1 Application.UnLock() [C#] Application.Lock(); Application["MyCode"] = 21; Application["MyCount"] = Convert.ToInt32(Application["MyCount"]) + 1; Application.UnLock(); [C++] Application->Lock(); Application->Item[S"MyCode"] = __box(21); Application->Item[S"MyCount"] = __box(Convert::ToInt32(Application->Item[S"MyCount"]) + 1); Application->UnLock(); [JScript] Application.Lock() Application["MyCode"] = 21 Application["MyCount"] = Convert.ToInt32(Application["MyCount"]) + 1 Application.UnLock()
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
HttpApplicationState Class | HttpApplicationState Members | System.Web Namespace
Show: