Task Running in wrong time

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
9 năm cách đây
Hi there!

I have noticed that all tasks run after an application restart, either by nop admin's menu or by IIS pool restart.

The tasks should verify their last-run-time and make the calculations to auto start or not after nop restart.

This is happening in my 3.3 nop.

Can you check?

Ivan.
9 năm cách đây
Hi Ivan,

Everything works fine. We already verify last-run-time. Please have a look at the \Libraries\Nop.Services\Tasks\TaskManager.cs file
9 năm cách đây
I see.

But even with the time check, all tasks run once after the restart, then they start running in their specific time configuration correctly.

I'll debug here to get more evidence.
9 năm cách đây
No, they are not run after restart only if specified "run period" is not passed since the last start
9 năm cách đây
Hi!

The problem is here:


            var notRunTasks = scheduleTasks
                .Where(x => x.Seconds >= _notRunTasksInterval)
                .Where(x => !x.LastStartUtc.HasValue || x.LastStartUtc.Value.AddSeconds(_notRunTasksInterval) <       DateTime.UtcNow)
                .ToList();


You compare the LastStartUtc with _notRunTasksInterval, that is 1800 seconds, and you should add the time configured in task, so this way, all my tasks are selected and are started one, by next code.

Check it, please.

Ivan.
9 năm cách đây
It's by design. nopCommerce finds task with "run period" set to more than 30 minutes and which were not run during last 30 minutes. It's not related to the issue you described in the original post.
9 năm cách đây
Please describe a complete list of steps to reproduce the issue (its "run period", etc)
9 năm cách đây
a.m. wrote:
It's by design. nopCommerce finds task with "run period" set to more than 30 minutes and which were not run during last 30 minutes.


This is what causing the "issue". All tasks ran exactly on their time (some 86400, others more), but after nop restart, that code detect that "were not run during last 30 minutes" and run them again.

If you are able to specify the run-time of a task, it cant run always when nop restart else if the run-time is over, or the task could do something wrong. Else we have to specify an exact hour or another time check inside each task to block the task execution, and then, specify a run-time is useless.

What do you think?

Ivan.
9 năm cách đây
I see now. It's related to tasks with "run period" more than 30 minutes. Thanks. I've just created a work item
9 năm cách đây
Fixed. Please see changeset 3f7a64c00e72. Thanks again for reporting
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.