Monday, 20 January 2014

Schedule a Job at specific Time using Global.asax

    void Application_Start(object sender, EventArgs e)
    {
        ScheduleTaskTrigger();
    }

    static void ScheduleTaskTrigger()
    {
        HttpRuntime.Cache.Add("ScheduledTaskTrigger",
                              string.Empty,
                              null,
                              Cache.NoAbsoluteExpiration,
                              TimeSpan.FromMinutes(60), // Every 1 hour
                              CacheItemPriority.NotRemovable,
                              new CacheItemRemovedCallback(PerformScheduledTasks));
    }
   
    static void PerformScheduledTasks(string key, Object value, CacheItemRemovedReason reason)
    {
        AutoMailService();
        ScheduleTaskTrigger();
    }
   
    static void AutoMailService()
    {
        //Your TODO
    }

No comments:

Post a Comment

Get all non-clustered indexes

DECLARE cIX CURSOR FOR     SELECT OBJECT_NAME(SI.Object_ID), SI.Object_ID, SI.Name, SI.Index_ID         FROM Sys.Indexes SI             ...