fire a method or event every hour automatically?

Discussion in 'ASP .Net Web Services' started by Monica, Jun 27, 2008.

  1. Monica

    Monica Guest

    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.
     
    Monica, Jun 27, 2008
    #1
    1. Advertising

  2. Monica

    Tanzim Saqib Guest

    On Jun 27, 10:03 pm, Monica <> 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
     
    Tanzim Saqib, Jul 1, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tom

    Page Load every 1 hour

    tom, Aug 18, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    363
    Mark Fitzpatrick
    Aug 18, 2003
  2. Replies:
    2
    Views:
    883
    Hal Rosser
    Jun 1, 2007
  3. ssylee
    Replies:
    4
    Views:
    519
    Thad Smith
    Jan 1, 2008
  4. Biranchi Narayan Panda

    Triggering an event in Windows service every 1 hour.

    Biranchi Narayan Panda, Feb 21, 2010, in forum: ASP .Net
    Replies:
    3
    Views:
    1,413
    Stefan Hoffmann
    Feb 21, 2010
  5. Chris Gunnels
    Replies:
    4
    Views:
    162
    Robert Klemme
    Sep 16, 2010
Loading...

Share This Page