Execution of a method in Global.asax

Discussion in 'General troubleshooting' started by toc2000, May 22, 2011.

  1. Hi,

    I've written some code in Global.asax that enables to periodically parse my new emails.
    Here is the code:

    protected void Application_Start()
    {
    AddTask("ListenToEmails", 60);
    }

    private static CacheItemRemovedCallback OnCacheRemove = null;

    private void AddTask(string name, int seconds)
    {
    OnCacheRemove = new CacheItemRemovedCallback(CacheItemRemoved);
    HttpRuntime.Cache.Insert(name, seconds, null,
    DateTime.Now.AddSeconds(seconds), Cache.NoSlidingExpiration,
    CacheItemPriority.NotRemovable, OnCacheRemove);
    }

    public void CacheItemRemoved(string k, object v, CacheItemRemovedReason r)
    {
    //Some code here

    // re-add our task so it recurs
    AddTask(k, Convert.ToInt32(v));
    }

    It works well on my local development environment but it doesn't seem to work when I publish it to my Winhost website.
    Do you know why? Is there a way to debug online?
     
    Last edited by a moderator: Oct 14, 2015
  2. Ray

    Ray

    Last edited by a moderator: Oct 14, 2015
  3. I finally subscribed to the ultimate plan and the Scheduled tasks work like a charm.

    Thanks
     
  4. Nice, glad to hear it.
     

Share This Page