Is it necessary to lock application state before accessing it ?
Answer Posted / kumar saurabh
Only if you're performing a multistep update and want the update to be treated as an atomic operation. Here's an example:
Application.Lock ();
Application["ItemsSold"] = (int) Application["ItemsSold"] + 1;
Application["ItemsLeft"] = (int) Application["ItemsLeft"] - 1;
Application.UnLock ();
By locking application state before updating it and unlocking it afterwards, you ensure that another request being processed on another thread doesn't read application state at exactly the wrong time and see an inconsistent view of it.
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are sql joins?
What is the significance of proxy user?
How do u declare static variable and how it is declared and what is its lifetime?
What is a session in asp.net?
What is the difference between c# and .net?
Difference between application events and session events
Define globalization and localization.
How many languages are supported by .NET at present time?
What are the advantages and limitations of query string?
Who is using asp.net?
What is Bundling and Minification in MVC?
How to find out what version of asp.net I am using on my machine?
Explain what does wsdl stand for?
How to deploy/publish webservices?How many ways?Plz explain me
Where is cookie used in asp.net?