Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > fire a method or event every hour automatically?

Reply
Thread Tools

fire a method or event every hour automatically?

 
 
Monica
Guest
Posts: n/a
 
      06-27-2008
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.
 
Reply With Quote
 
 
 
 
Tanzim Saqib
Guest
Posts: n/a
 
      07-01-2008
On Jun 27, 10:03 pm, Monica <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Triggering an event in Windows service every 1 hour. Biranchi Narayan Panda ASP .Net 3 02-21-2010 06:18 PM
function reading hour register either in 12 or 24 hour formats andreturning properly ssylee C Programming 4 01-01-2008 03:11 AM
SimpleDateformat: 12 hour versus 24 hour techshiv@gmail.com Java 2 06-01-2007 09:51 PM
Re: 24 hour <--> 12 hour vcr clock fred@nospam.com Computer Support 0 08-14-2004 07:26 AM
24 hour <--> 12 hour vcr clock fred@nospam.com Computer Support 4 08-13-2004 01:52 PM



Advertisments