fire a method or event every hour automatically?

M

Monica

Hi there,

I am new in web services and I am not sure it's related to web services.
Is it possible a web application automatically fire a method or event every
hour?

It shouldn't be depend on aspx pages.

Regards,
Monica.
 
T

Tanzim Saqib

Hi there,

I am new in web services and I am not sure it's related to web services.
Is it possible a web application automatically fire a method or event every
hour?

It shouldn't be depend on aspx pages.

Regards,
Monica.

Hey Monica

If Windows Service if forbidden on your side, you can still do it
hopefully by a trick.

ASP.NET Worker process frequently looks for Cache items whether they
expired. You can harness this feature. On Application_Start inside
global.asax, add a dummy cache item using
HttpContext.Current.Cache.Add. In the method signature you will see
the last item is System.Web.Caching.CacheItemRemovedCallback which is
a delegate that gets fired upon expiration of this cache item.

When it is fired, the code you specified in the handler gets executed
and again add the dummy cache item you inserted before. That will do
the trick. It can be like the following:

HttpContext.Current.Cache.Add(dummyKey, "dummy", null,
DateTime.MaxValue, TimeSpan.FromMinutes(60), CacheItemPriority.Normal,
new CacheItemRemovedCallback(CacheItemRemovedCallback));

....

public void CacheItemRemovedCallback(string key, object value,
CacheItemRemovedReason reason)
{
// Code you would like to get executed.
// Add the dummy item to the Cache like above.
}

Hope it helps.

Tanzim Saqib
http://www.TanzimSaqib.com
 

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

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top