Is it necessary to lock application state before accessing it ?



Is it necessary to lock application state before accessing it ?..

Answer / 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

More ASP.NET Interview Questions

what is caching,session? when & what is used mostly in which situtations, how they r implemented in real time? tell with example?

1 Answers   Satyam,


Explain weak typing and strong typing.

0 Answers  


Can we make activex dll also ti execute in some process as that of client ? How can we do?

0 Answers   DELL, Zerone,


What is a web pool?

0 Answers  


can we edit records from repeater control

2 Answers  






What is the difference between ldap and active directory?

0 Answers  


What is csrf attack in asp.net?

0 Answers  


Differentiate between client-side and server-side validations in web pages.

0 Answers  


what is shared assembly asp net

1 Answers   Fidelity,


can we remote debug applications with the remote debugger installed with vs.net 2002, with vs.net 2003?

0 Answers  


What is Difference between Callbacks and Postback in ASP.NET?

11 Answers  


What are validator? Name the validation controls in asp.net? How do you disable them?

0 Answers  


Categories