Application or Cache?

Hi, I want to use a global variable (all users) on a site.

On each request, I need to modify a variable, lets say it is a counter for example.
I found many examples using this approach:

Aplication("counter") = Aplication("counter") + 1

But I found too that using the lock-unlock can affect the performance of the web application.
What is the best method for doing this on ASP.NET?
can I use the Cache object for this?
thank you
8/3/2003 11:18:54 AM 8807 articles. 0 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 7

The Cache object does basically the same thing. It uses a lock to prevent thread race conditions.

I recommend using the Interlock class to increment your application variable in a thread safe manner.
Although I'm not sure this will work. You integer is boxed, so the reference is unboxed before it's incremented. This means that you will only be incrementing your local stack's copy of the variable, not the Application's copy.
Anyway, give that a shot... see if it works.
8/5/2003 5:34:23 PM

Similar Artilces:

Creating a Cache Manager to Manage the cache
Hi experts, I have a small question regarding the Caching of Data in ASP.NET. In my application I have XML data that I require to be cached for a one time only Load into memory at Application Domain startup. There is vast amount of date here that I want to use later to query using XPath Queries. What I wanted to do was use a Separte Cache Manager that I was going to custom build. What I did was create a class, this class was defined as shared in my application, and I wanted a one time only instatnce of this class (singleton). What this class encapsulates is the some of the method...

Writing using 'ResXResourceWriter' in Web Application, clears the Session, Cache, Application states
See the below code: //------------------------------------------------- 1 ResXResourceWriter rw = new ResXResourceWriter("MyResource.aspx.en-GB.resx");2 rw.AddResource("StringData", "My String");3 rw.AddResource("IntegerData", 2);4 ........5 rw.Close(); //------------------------------------------------- In my ASP,NET Web Portal, I am using the above code to do the 'Translation' functionality. Actually the need is allow a Administrator to define the translation of the Web-Pages for the various languages at runtime. This all is happening at the run time.But the probelm is once the system...

How to Run my .exe file or Application in the Background using .NET Application like explorer.exe file is Running always in the Background...(you can see in task Manager..)
Hi , This is Sundar , i want to develope one small Application in windows or web ,that should send the mail continiously according to at what time scheduled in the application and that should Running in the Background always like windows service,SQL server ........ so , please help me ......................  what;s the problem if you develop an windows service and install it in your system. a man a fish and you feed him for a day. Teach a man to fish and you feed him forever.  see, i have created the Windows services and wh...

State management web application.
Hi, I have a question regarding state management. I know that Http is stateless protocol. I am using a server side Object SESSION object for maintaing the state of the User. But i have some confusion when i have to use SESSION object.  When i user Login then i save a UserName and Password in the SESSION object on server side as follow. Session["UserId"]  = loginModel.getUserName(); Session["Passwor"]  = loginModel.getPassword(); but i have question that when i save these two values in Session object, and on next request of the web page how the web serv...

managing state for aweb application
 hii want to know all in this topic managing state for aweb application with code or video the vidao is bestthanks as an answer if it helps.  i want all states view state ,contorol state, application,session Hi, eng_oss_csharp:  i want all states view state ,contorol state, application,session Please check following links: [How Do I:] Make use of Caching? Great ASP.NET 2.0 Tutorial Videos Online

Understanding Application and State management
Im having great difficulty in understanding Application State and Session State. I've read MSDN and a few other sites and none make a great deal of sense in helping me understand. Can anyone help me understand these two and possibly provide me with a few example websites with application state and session state to increase my understanding on these two topics. Thank you in advance Hi, try QuickStart tutorials:,Teemu KeiskiFinland, EU...

Custom Application State Management
Is there any way to override the HttpApplicationState object, so that anytime pre-existing code attempts to read from or write to the Application object I can take control? I need to come up with custom Application State managment to be used across a web farm.  The built in methods of StateServer or SQLServer would probably work, but would be a substantial performance hit, as we have no need to share Session state (which can get large) across servers, just Application. (the user will not switch servers within a given session) Our solution will probably be to manually se...

State Management; .Net Profiler
Here is the situation with the customized profiler. I got a profiler class called SSOProfileProvider inheriting from ProfileProvider. I've implemented the Initilization, GetPropertyValues and SetPropertyValues. The Get... and Set.. are making a call to the database to store profile into the database. This class has been stored in the separate DLL called "Security.DLL" and there is a web site that is using this dll. The web.Config for this website is as follow:<profile enabled="true" inherits="AppProfileBase" defaultProvider="SSO" automat...

Using .net AJAX enabled application in non .net Web Application
Hi,Does anyone have similar experience in development?  I want to check if it's possible to run .net ajax object (from one standalone .net framework platform in company) with non .net application (i.e. J2EE web application)?  It is because we want to add certain feature (i.e. office communicator chat) to our exist application (oracle J2ee). Please give me some advice :) Thanks! Hi, .Net AJAX is based on .Net Framework architecture. Thus .Net Framework currently lacks support for other platforms, such as Java. Please check this link:

Data Caching versus Application State
I have 1000 companies logging in. each company has their own set of lookups tables which they will require regularly so I want to save roundtrips on these. Lets take the STAFF table as an example. The STRUCTURE of this table will be the same for each company but the DATA inside will obviously differ. As I see it there are 2 ways I can do this. Can anyone offer me advice please re performance best method etc. 1. Put each lookup table in a seperate data cache object with part of key containing unique CompanyID. advantages: data cache so memory scavenging etc. disadvantages: possibl...

State Management : Data Stored in Application
Hello, I'm in the process of migrating an ASP.NET 1.1 site to 2.0. One of the problem I encounter is the change of behavior of the framework calling "Application_Start" in global.asax.cs. Basically : 1) Issue an IISRESET to make sure to start from scratch. 2) Access a page in the site : "Application_Start" is called. During this call, I check database access and other few things and store the database state in the application cache. 3) Wait until the ASP.NET process is recycled due to inactivity. 4) Access the site again. "Application_Start is not called", so Application cache is mi...

Application state management? (N00b question?)
Hi Folks - be nice to me, I'm new and I may have done something stupid. Basically I have a PVR controller web application I'm working on, but I can't seem to get the timer functionality (to control the start & stop actions of the PVR) to stay alive.  I built a class and initialised it in the application scope so as far as I understand it it should only have one instance of this class, but it seems to create multiple instances (which cannot connect to the PVR as it only allows a single connection and fail).  When the class is running then it appears to work correctly, but ...

How to manage the session state outside the application
Hello Dear,i m facing some problem with my web application (developing in ASP.Net). i want to manage the session even after i closed the application on client if any client 'ABC' open my web application 'XYZ' then after some time when clent 'ABC' close the browser ie Application 'XYZ'. then after some time again open the application on same client 'ABC'. Plz tell me how i can maintain the same session on that client without assign new session to that client 'ABC'. can i solve this problem by storing the session in SQL Server.i don't want to create any cookie. plz give reply ...... ...

Managing Application State
What's the appropriate way to manage Application state using locks?I've googled around and seen the following:Application.Lock() Application["Test"] = 1; Application.Unlock();static object obj = new object();lock(obj){     Application["Test"] = 1;}static ReaderWriterLock rwl = new ReaderWriterLock(); rwl.AcquireWriterLock(1000); Application["Test"] = 1; rw1.ReleaseWriterLock();  I'm thinking:The first method prevents any other thread from accessing the Application object until Unlock is called.  The second method i...

Design Patterns in .NET Cache Management.
Hi, 1. What are the design pattern(s) used or involved in the .NET Cache Management? 2. If possible, classify it or them in terms of category.Where there is a will, there is a way. and where there is a team, there is more than one way. So, nobody is here to do your homework for you, and if your professor/teacher happens to find this, he/she may very well not be too pleased to find out you're soliciting answers to your homework questions. If you've got specific questions, feel free to ask them, but copying straight out of the end of the chapter or the worksheet isn't going to wor...

Web resources about - Application or Cache? -

Application - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

The Bachelor 2016 application process can get explicit - Laurina Fleure
CHANNEL Ten is calling on singles to sign up for a chance to find love on The Bachelor , but willing applicants have to open a lot more than ...

Perth man’s Afghan wife slapped with 10-year visa application ban - PerthNow Search Search
A MAN’S three-year struggle to have his wife live with him in Australia has ended in heartache after his spouse was slapped with a 10-year ban. ...

Application developers struggle to adapt to changing licensing models
Application producers are aware of rapid change impacting their ability to make money from their software products, but they're not adopting ...

MBA: Mortgage Applications Decrease in Latest MBA Weekly Survey, Purchase Applications up 30% YoY
From the MBA: Mortgage Applications Slightly Decrease in Latest MBA Weekly Survey Mortgage applications decreased 0.2 percent from one week ...

Elon Musk Requests Applications For Autopilot Software Engineers On Twitter
... and more quickly achieve “generalized full autonomy.” So, if you ever wanted to work for Tesla in such a [&hellip Elon Musk Requests Applications ...

Mortgage applications down 0.2%
Mortgage interest rates haven't moved much in the past three weeks, but they are holding at a higher level than for all of 2015.

Number Of Daily Applications To French Military TRIPLES Overnight
Number Of Daily Applications To French Military TRIPLES Overnight

LED market saturation to drive industry to seek profits in new applications in 2016, says LEDinside
According to LEDinside, LED makers had an especially tough year in 2015. "Despite rising LED lighting market demand and the large scale replacement ...

Windows 10’s broken fall update removes user-installed applications without asking first
Microsoft's latest Windows 10 update is causing problems for at least some users, and uninstalling programs without the user's consent or evidence ...

Resources last updated: 12/3/2015 7:33:24 PM