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

How to convert any string to view state format in asp.net? §ÇÛ짬ªª³ö»Ç¾ö»ÂÇ¿¾»¼»¾ö¼ÉÇöÇÏǼ»Ãö®±ª§°ö«³ -- i want convert this string to view state.

1 Answers   iFlex,


Difference Between GridView And DataList

2 Answers  


What do you mean by authentication?

0 Answers  


Define ViewState and how can it be used?

6 Answers   Siebel,


Why do we use sessions?

0 Answers  






Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.

1 Answers  


What?s the difference between Response.Write() and Response.Output.Write()?

2 Answers   Siebel, Visual Soft,


I have a component with 3 parameter and deployed to client side now i changed my dll method which takes 4 parameter.How can i deploy this without affecting the clent?s code ?

1 Answers   Microsoft, Satyam, Wipro,


how many script manager controls are used in Ajax web page?

7 Answers   CSC, Health Prime Services, TCS,


What are the modes of updation in an updatepanel?

0 Answers  


What is cookieless session id explain in brief?

0 Answers  


Can you change a Master Page dynamically at runtime?

0 Answers  


Categories