Scheduled Tasks will not run in Custom Classes in Kentico 11

Thalia Hahn asked on April 30, 2021 06:49

I have built 2 custom scheduled tasks under my 'Site1' on an instance of Kentico 11. There are several scheduled tasks running under 'Site1'. Most run code from Kentico's CMS libraries such as CMS.Membership.DeleteNonActivatedUser.

My 2 Custom Scheduled tasks reside in the App_Code folder.

using CMS;

using CMS.EventLog;

using CMS.Scheduler;

using System;

[assembly: CMS.AssemblyDiscoverable]
[assembly: RegisterCustomClass("CustomTask1", typeof(namespaceName.CustomTask1))]
[assembly: RegisterCustomClass("CustomTask2", typeof(namespaceName.CustomTask2))]
namespace namespaceName
{
public class CustomTask1 : ITask
{
    public string Execute(TaskInfo task)
    {
        try
        {
            EventLogProvider.LogEvent(EventType.INFORMATION, "CustomTask1", "Task Begin", "Task is 
        working.");

        }
        catch (Exception ex)
        {
            EventLogProvider.LogEvent(EventType.ERROR, "CustomTask1", "Task Error", "Task threw                                                                          
             exception: " + ex.Message);
        }

        return null;
    }

}

public class CustomTask2 : ITask
{
    public string Execute(TaskInfo task)
    {
        try
        {

            EventLogProvider.LogEvent(EventType.INFORMATION, "CustomTask2", "Task Begin", "Task is 
        working.");
        }
        catch (Exception ex)
        {
            EventLogProvider.LogEvent(EventType.ERROR, "CustomTask2", "Task Error", "Task threw              
            exception: " + ex.Message);
         }
         return null;
       }
   }
}

My CustomTask1 and CustomTask2 appear in the Class dropdown list in the Kentico Task Scheduler. I've set both Tasks up to run every day at 6:00 AM. and the Enabled checkbox is checked. none of the checkboxes below are checked. When I click the green triangle on the task list page I get the popup message that says it's running. But nothing is logged in the event logs and neither the last run datetime nor the run counter change.

Does anybody have any idea what is causing this? I have multiple custom scheduled tasks running in a different instance of Kentico and they are working fine, but I cannot get this instance to run my custom tasks.

Any ideas?

Recent Answers


Jake Kula answered on May 3, 2021 23:52

Hi Thalia,

Have you tried setting a breakpoint in your code to see if the you're able to step into the code by debugging?

Also, is this a website or web application project?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.