The UI Toolkit has a Timer control (question 2437) - use it when the toolkit is available. On toolkits without it, a timer coach view is ten lines:
// Coach view "Timer" - options: interval (Integer, ms), autoStart (Boolean); binding: Integer (ticks); boundary event on tick
// load handler
var me = this, handle = null;
me.start = function () { if (handle) return; handle = setInterval(function () {
var n = (me.context.binding.get("value") || 0) + 1;
me.context.binding.set("value", n);
me.context.trigger(function () {}, { tick: n }); // fires the view's boundary event -> CSHS can call a service, refresh a table, etc.
}, me.context.options.interval.get("value") || 5000); };
me.stop = function () { if (handle) clearInterval(handle); handle = null; };
if (me.context.options.autoStart.get("value")) me.start();
// unload handler: me.stop();Typical uses: poll a service every N seconds (${Timer}'s boundary event > Stay on page > service flow > back to the coach), a countdown to the task due date (${Countdown}.setText(...)), auto-save drafts. Rules: always clear the interval in unload (otherwise the timer keeps running after the coach is gone), keep intervals ≥ 5 s for polling, and stop polling when the tab is hidden (document.hidden).
Alternatives: newer toolkits offer the Timer control with an on timeout event and start / stop methods; for server-side waiting inside a BPD use a timer intermediate event, not a coach timer (question 54).
References