method setForOffset

void setForOffset(object callbackObject,string method,int32 timeout);

Argumente

Zurückgegebener Wert

This method sets a timer to fire the specified method from the callbackObjectonce after waiting for timeout milliseconds from the current time. If the timeout 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;

    // register timer callback method to fire after 5 seconds
    timerObj.setForOffset(myTimerCallback, methodName, 5000);
}