How To Update Application Var in class-method that I start in Thread

Hi,
My Problem: I need to run a method that constantly updates DB on Application level and alerts clients if there are updates maden, using an Application variabel (a counter) so I
thought, let's set up a Thread in the global.asax, calling the method. But I can't update a Application var in a method (Application does not exist in current context)

in app_code: class CheckIfOpen method: IsOpenForBiding
in global.asax:
Thread th = new Thread(new ThreadStart(CheckIfOpen. IsOpenForBiding));
th.IsBackground = true;
th.Start();
But how do I fit in Application["OnSaleCounter"] ???

Friendly greetings,
Jürgen



Jurgen ThysC# DeveloperAsked:
Who is Participating?
 
Anurag AgarwalConnect With a Mentor Commented:
Httpcontext exist in system.web thus you may also use system.web.Httpcontext.Current.Application["OnSaleCounter"]
0
 
Anurag AgarwalCommented:
hello jurgen !!

to find Application["OnSaleCounter"] try

Httpcontext.Current.Application["OnSaleCounter"] = value

0
 
Jurgen ThysC# DeveloperAuthor Commented:
Thanks very,
Simple if you know it, frustrating if you don't!

Jürgen,
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.