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
Describe state management in asp.net?
What is the maximum amount of memory any single process on windows can address?
Explain about solution explorer window?
Can we have multiple master pages in asp net?
What are the session management techniques asp net?
Define the types of configuration files.
Difference between application events and session events
What is the difference between user control and custom control?
How can we call webservices in Banking Applications? and where we are using it?
What describes a query?
Disable browser cache for entire ASP.NET website?
What are the namespaces used in asp.net mvc? : asp.net mvc
What are demand-paging and pre-paging?
How do you remove duplicates without using remove duplicate stage?
Explain the different types of directives in .net?