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 |
What is difference between view and partial view?
Explain how dot net compiled code will become platform independent?
List the types of authentication supported by asp.net?
What are the differences between primary foreign and unique keys?
Why is catch(Exception) almost always a bad idea?
what is soap?
5 Answers Cognizant, Microsoft, NCR,
What is cross page posting in asp net?
How do I debug an ASP.NET application that wasn't written with Visual Studio.NET and that doesn't use code-behind?
can we pass values from one page to another page without redirecting to that page?
6 Answers Google, Patni, Syntel, Wipro,
What is application variable?
How Session use Cookies in State Management?
How to automatically get the latest version of all the asp.net solution items from source safe when opening the solution?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)