Application object and System.Timers.Timer

S

Shawn B.

Greetings,

I have a object that gets created and interted into the Application object
of my ASP.NET application, that internally contains a Timer that elepses
every so often (once a minute by default).

In the event that it raises, I must access the Application object and work
with some things that are stored in it.

The problem is that the Application object is always null when this
happens... e.g. System..Web.HttpContext.Current.Application always returns
null.

My guess is that it only has a current context during a page request and
since this isn't happening inside a page request, it is null.

My question is, how can I access this Application object? It is global so
it should be there, unlike the Session and so on.

Before I get answers about the usual (make it a service) you must understand
that this is not an option for me, the project is on a hosted server and I
don't have the ability to deploy a service (unless I pay unfathomaly amounts
of money to have them review the code, test it, and whatever else before
they'll deploy it).


Thanks,
Shawn
 
S

Shawn B.

I can usually predict when I'm about to solve the problem by the mere fact
that I'm posting to a group for help, before that, no matter how long I
struggle, the point is that I struggle.

I solved the problem by passing a reference to Application into my object
that it keeps privately, so when the timer elapses, I don't look in
Context.Current.Application, instead I use the private reference. Seems to
work like a champ.

Still, if anyone has any other answers, please post.


Thanks,
Shawn
 
S

Scott Allen

Hi Shawn:

Greetings,

I have a object that gets created and interted into the Application object
of my ASP.NET application, that internally contains a Timer that elepses
every so often (once a minute by default).

In the event that it raises, I must access the Application object and work
with some things that are stored in it.

The problem is that the Application object is always null when this
happens... e.g. System..Web.HttpContext.Current.Application always returns
null.

My guess is that it only has a current context during a page request and
since this isn't happening inside a page request, it is null.

That's exactly what happens.
My question is, how can I access this Application object? It is global so
it should be there, unlike the Session and so on.

Before I get answers about the usual (make it a service) you must understand
that this is not an option for me, the project is on a hosted server and I
don't have the ability to deploy a service (unless I pay unfathomaly amounts
of money to have them review the code, test it, and whatever else before
they'll deploy it).

I don't believe the object is exposed anywhere from a public
shared/static property. The solution you came up with is probably the
best approach.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top