It's unlikely that the locking the ASP Application
object will result in a deadlock lasting longer than the server script timeout setting.
The classic ASP Application
object has Lock and Unlock for synchronizing changes to the Application objects. You can have multiple requests trying to make a change to the same value - without locking, making the change and then unlocking the change might be lost.
As simple example would be a counter of some sorts. Let's say your code does:
<%
Application("Count") = Application("Count") + 1
%>
If you have two simultaneous requests (req1 and req2) , you could "lose" a page hit - effectively a "missing update".
You can prevent this by locking the Application
variable before updating it and unlocking it after the update:
<%
Application.Lock
Application("Count") = Application("Count") + 1
Application.Unlock
%>
If Application
is locked while another request thread tries to access it, the thread will block until the lock is released or the script timeout is exceeded.
If you forget to Unlock a Lock it will be released automatically after the page is processed or after the script timeout is exceeded.
For more information, see MSDN.