PDA

View Full Version : Question about DelayedTask



parky128
2 Feb 2012, 5:58 AM
Hi,

I am trying to get a DelayedTask function to loop at a set interval using the following code:



this.delayedRefreshTaskInterval = 5000;

this.delayedRefreshTask = new Ext.util.DelayedTask(function(){
this.raiseEvent('checkforupdates');
this.delayedRefreshTask.delay(this.delayedRefreshTaskInterval);
}, this);


I am defining the above code in my launch function of my application code, not sure this is the correct thing to do actually??

I can kick this off elsewhere in some controller code by doing:



this.getApplication().delayedRefreshTask.delay(this.getApplication().delayedRefreshTaskInterval);


The 'checkforupdates' call in the function does get fired after 5 seconds, but it doesn't continue to get fired every 5 seconds as I would expect.

Where am I going wrong here please?

estesbubba
2 Feb 2012, 6:33 AM
I think DelayedTask is a one and done. Try a task.delay() again once the timer pops.

parky128
2 Feb 2012, 6:40 AM
But I am calling delay within the function itself after I do what I need to do, so it then calls itself again after the set interval period elapses.

wenying.yang@hp.com
15 Jan 2013, 9:46 PM
hi, i meet the same issue when using delayedtask, the thing is if in debug mode, step into the delay method once, it scheduled correctly... any idea?