This method sets a
timer to fire once at an absolute (non-repeating) time.
If the
timeToFire is equal or less than zero then the callback is called immediately.
The timer will not be set if either the
callbackObject or
method is invalid.
If
timer has already been set before calling this method and has not fired yet then,
it is reset with current parameters.
var timerObj;
//constructor function for our sample timer listener object
function myTimerCallBack()
{
this.handleMyTimer = handleMyTimerFunc;
}
//timer callback method
function handleMyTimerFunc()
{
alert("This is my timer callback.\n");
}
//main method
function onInitialized()
{
var objCallback = new myTimerCallBack;
registerMyTimerListener(objCallback, "handleMyTimer");
}
function registerMyTimerListener(myTimerCallback, methodName)
{
timerObj = shell.serviceManager.basics.timer;
var dateObj = new Date();
dateObj.setMinutes(dateObj.getMinutes() + 1);
// register timer callback method to fire after 1 minute from the current time
timerObj.setForTime(myTimerCallback, methodName, dateObj.getVarDate());
}