Bug reports Found a bug? Post it here please.
Version 7.x > Bug reports > Scheduled Tasks View modes: 
User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 12/4/2012 12:37:03 PM
   
Scheduled Tasks
In my opinion this is a bug because the sequence of events isn't right. I've created a scheduled tasks that runs every 5 minutes. What I'd like to pass as a parameter to my method is the TaskInfo.TaskLastRunTime value. When I debug the application it appears the TaskLastRunTime, TaskNextRunTime and TaskExecutions are all updated prior to the custom task code being called. So when the custom task runs, it always shows the TaskLastRunTime as the current time. There might need to be a TaskLastExecutedTime field as well. Execute and Run are two different things. Again, in my opinion, TaskLastRunTime would mean successful with no errors or exceptions and the time would be updated after the task successfuly completes vs. when it starts or is executed.

Is there a way around this? I could take the TaskLastRunTime and subtract 5 minutes from it although it isn't a true value because someone could manually run the task 2 minutes after it was last run then I would get duplicate records.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 12/6/2012 2:50:30 AM
   
RE:Scheduled Tasks
Hi,

currently, there is no way how to say that the task execution will finish OK or when. What is certain, is that it was launched and this is the last run time as well. However, there are planned some changed in the scheduler core to improve also these things. Currently, it is by design and you would need to add some custom code which will be executed at the end of your task.

Best regards,
Juraj Ondrus

User avatar
Certified Developer 11
Certified Developer 11
felix.planjer - 7/18/2013 4:19:21 AM
   
RE:Scheduled Tasks
Hi, we also have the need to know the last Successful execution of the Task.

For this we use the TaskData field. In the task use ti.TasData to write data into the field and the next run we can read it back This data could be a LastSuccessFulRun or any other things you need to 'remember'.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 7/18/2013 10:47:43 AM
   
RE:Scheduled Tasks
I use that field for parameters as well and it works fairly well but still not ideal.