PDA

View Full Version : Ext.util.TaskRunner



Farshad
8 Mar 2011, 3:03 AM
Ext JS version: 3.3.1

When TaskRunner is started for first time, it fires first event at wrong interval. The interval which first event is fired is the interval you pass as the constructor parameter not the interval of the currently started task.

I investigated thet code and noticed that bug is in below code:



this.start = function(task){
tasks.push(task);
task.taskStartTime = new Date().getTime();
task.taskRunTime = 0;
task.taskRunCount = 0;
startThread();
return task;
};

Correct code should be something like this:


this.start = function(task){
tasks.push(task);
task.taskRunTime = task.taskStartTime = new Date().getTime();
task.taskRunCount = 0;
startThread();
return task;
};Sample test case:


var updateClock = function(){
Ext.fly('clock').update(new Date().format('g:i:s A'));
}
var task = {
run: updateClock,
interval: 5000 //5 seconds
}
var runner = new Ext.util.TaskRunner(50); // 50 ms timer resolution
runner.start(task);

silentsakky
10 Mar 2012, 10:31 AM
i have same problem, can anyone confirm this?