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
Difference between using directive vs using statement?
What is asp.net and its advantages?
Explain diff. Between friend and protected friend?
How does http session work?
What I need to create and run an asp.net application?
Define the term Scavenging in Caching?
Explain the difference between globalization and localization techniques
List the events in page life cycle.
What is mvc in asp.net tutorial? : Asp.Net MVC
What is a 1x1 pixel?
How many ways are there to maintain a state in .net? What is view state?
Explain cookies with example.
What is view state and how it works in asp net?
Where sessions are stored?
Which object encapsulates state or data of a user?