Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Services (http://www.velocityreviews.com/forums/f64-asp-net-web-services.html)
-   -   fire a method or event every hour automatically? (http://www.velocityreviews.com/forums/t787606-fire-a-method-or-event-every-hour-automatically.html)

Monica 06-27-2008 04:03 PM

fire a method or event every hour automatically?
 
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.

Tanzim Saqib 07-01-2008 01:38 PM

Re: fire a method or event every hour automatically?
 
On Jun 27, 10:03 pm, Monica <Mon...@discussions.microsoft.com> wrote:
> 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


All times are GMT. The time now is 11:18 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.