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
What is the difference between a default skin and a named skin?
What is autopostback true?
Explain what are delegates?
Can we create a multiple user simultaneously ?
Explain the differences between clr & cts?
Which object wraps the state or data of a user?
How do we assign page-specific attributes?
What is route in web api?
How many types of state management are there in asp net?
Explain what is an assembly?
Error : The operation couldn’t be performed because ole db provider sqlncli10 for linked server was unable to begin a distributed transaction.00000110 oledb provider for linked server returned message the partner transaction manager has disabled its support for remote/network transactions. I can able to execute the stored procedure in sql server but when i run the web page getting error like above. I did all the configuration. what is the solution?
How does asp.net work?
What is the difference between table and query?
ASP.NET 2.0's new membership API used for creating and managing user account is exposed through which 2 clause?
What is the difference between executescalar and executenonquery?