DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

Troubleshooting scheduled task hanging after completion DNN 7.4.2

 1 Replies
 1 Subscribed to this topic
 40 Subscribed to this forum
Sort:
Author
Messages
Isa
New Around Here
Posts: 2
New Around Here
New Poster
New Poster
Congrats on posting!

Recently, a task has started to hang around after completion. It is happening just for this task, just in this install, and I don't understand why.

Not sure how relevant this will be. The task is scheduled to run every 30 minutes. But it can also be scheduled by another task or database connection timeout via:

var schedulingProvider = SchedulingProvider.Instance();
var scheduleItem = schedulingProvider.GetSchedule(typeFullName, null);
schedulingProvider.RunScheduleItemNow(scheduleItem, true);

The task is fairly basic:
1. Load queued records
2. Call the stored procedure on every record
3. Exit

Task can terminate early if SQL connection times out. After which, the task would attempt to reschedule itself.

Most of the time, the task has nothing to do. It completes in a fraction of a second (0.10 - 0.19 seconds).

Recently, the task started to hang ever other time. Each time I manually stop the task in the Schedule Status window, it would have STARTED_FROM_SCHEDULE_CHANGE in the Triggered by column. My understanding is that this indicates the task was started by either the Edit Schedule window (Update or Run Now buttons) or from the SchedulingProvider instance's RunScheduleItemNow method.

At first I thought the task was getting lost by the worker process. I added (SchedulerClient) Progressing calls to the batch processing loop in the hope that it would update ScheduleHistory.LogNotes as it runs and keeps the worker process happy. But nothing changed, so I thought the task was not executing at all. I added logging to every method that is entered and exited. Now, each time the task runs, I get the following:

2026-03-18 10:19:08,271 [WebSvr02][Thread:178][ERROR] DotNetNuke.Services.Exceptions.Exceptions - System.Exception: Entered DoWork method
2026-03-18 10:19:08,271 [WebSvr02][Thread:178][ERROR] DotNetNuke.Services.Exceptions.Exceptions - System.Exception: Entered ExecuteAcademicRatioUpdate method
2026-03-18 10:19:08,271 [WebSvr02][Thread:178][ERROR] DotNetNuke.Services.Exceptions.Exceptions - System.Exception: Entered ProcessQueue method
2026-03-18 10:19:08,271 [WebSvr02][Thread:178][ERROR] DotNetNuke.Services.Exceptions.Exceptions - System.Exception: Entered ProcessBatch method
... snip loop logs for brevity ...
2026-03-18 10:19:08,490 [WebSvr02][Thread:178][ERROR] DotNetNuke.Services.Exceptions.Exceptions - System.Exception: Exiting ProcessQueue method
2026-03-18 10:19:08,490 [WebSvr02][Thread:178][ERROR] DotNetNuke.Services.Exceptions.Exceptions - System.Exception: Exiting ExecuteAcademicRatioUpdate method
2026-03-18 10:19:08,490 [WebSvr02][Thread:178][ERROR] DotNetNuke.Services.Exceptions.Exceptions - System.Exception: Entered HandleSuccess method
2026-03-18 10:19:08,490 [WebSvr02][Thread:178][ERROR] DotNetNuke.Services.Exceptions.Exceptions - System.Exception: Exiting HandleSuccess method
2026-03-18 10:19:08,490 [WebSvr02][Thread:178][ERROR] DotNetNuke.Services.Exceptions.Exceptions - System.Exception: Exiting DoWork method

This confirmed that the task runs and the DoWork method completes. At which point I expect the worker process to move on to the next task.

I don't know if it is related, but my DoWork method is currently implemented as follows:

public override void DoWork()
{
    Exceptions.LogException(new Exception("Entered DoWork method"));
    var executionResult = ExecuteAcademicRatioUpdate();

    if (executionResult.TimeoutOccurred)
    {
        HandleTimeout(executionResult);
    }
    else if (executionResult.HasErrors)
    {
        HandleErrors(executionResult);
    }
    else
    {
        HandleSuccess(executionResult);
    }
    Exceptions.LogException(new Exception("Exiting DoWork method"));
}

Any suggestions are much appreciated.
 

Isa
New Around Here
Posts: 2
New Around Here
New Poster
New Poster
Congrats on posting!

I resolved the issue by refactoring my DoWork method.

Namely, I ditched HandleTimeout altogether and wrapped HandleSuccess and HandleErrors in a try..catch block as per examples.

I also removed all Progressing methods as these don't seem to do anything.

I tried Started and Completed methods. They worked, but the task kept rescheduling itself as soon as it was completed. Causing issues with the scheduler thread. Where active/free thread count would go negative. This results in multiple tasks running simultaneously.

Reference:
Creating Scheduled Jobs - https://www.dnnsoftware.c...ating-scheduled-jobs
DotNetNuke Scheduler (Schedule a Task in DNN) - https://www.dnndeveloper....hedule-a-task-in-dnn
 

These Forums are for the discussion of the open source CMS DNN platform and ecosystem.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
  2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
  3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  5. No Flaming or Trolling.
  6. No Profanity, Racism, or Prejudice.
  7. Site Moderators have the final word on approving / removing a thread or post or comment.
  8. English language posting only, please.

Would you like to help us?

Awesome! Simply post in the forums using the link below and we'll get you started.

Get Involved