Vb.net application. lock usage
The application mechanism is effective for the entire website. All users who visit the website enjoy the same application, which is different from the session mechanism.
After locking other pages, application operations cannot be performed at the same time. You can use the pv element of the operating system to understand
<% @ Page language = "vb" autoeventwireup = "false" codefile = "default. asp tutorial x. vb" inherits = "_ default" %>
<! Doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> untitled page </title>
</Head>
<Body>
<Form id = "form1" runat = "server">
<Div>
The page has been requested
<Asp: label id = "mylabel" runat = "server"/>
Times!
</Div>
</Form>
</Body>
</Html>
File: default. aspx. vb
Partial class _ default
Inherits system. web. ui. page
Protected sub page_load (byval sender as object ,_
Byval e as system. eventargs) handles me. load
If application ("pagecounter")> = 10 then
Application. remove ("pagecounter ")
End if
If application ("pagecounter") is nothing then
Application ("pagecounter") = 1
Else
Application. lock ()
Application ("pagecounter") + = 1
Application. unlock ()
End if
Mylabel. text = application ("pagecounter ")
End sub
End class
Lock and unlock are used in pairs. They are all effective for the entire website. When the lock is released and the unlock lock information is completed in an instant, you don't actually feel it. if you use lock, it will control your entire website.