Rich UI job scheduler

You can try the following example in your workspace:
import com.ibm.egl.rui.widgets.Button;
import egl.javascript.Job; 

handler MyHandler type RUIhandler { initialUI = [stopButton],
                                    onConstructionFunction = initialization }

   stopButton Button{text="Stop!", onclick ::= pleaseStop};	
   doThis Job{runFunction = myRunFunction};

   function initialization()
      doThis.repeat(1000);
   end

   function myRunFunction()
      sysLib.writeStdOut(currentTime());
   end

   function pleaseStop(e event in)
      doThis.cancel();
   end
end
Use of this capability requires that you type the following import statement:
   import egl.javascript.Job; 

You cannot add that statement with the Ctrl-Shift-O mechanism that is available for Widget types.

Two definitions may clarify the relationships:
The job scheduler is a variable based on an EGL external type named Job. When you declare the variable, you can set the following properties:
name
Used by the EGL debugger to identify the job scheduler. If you omit this property, the value of name is the variable name.
runFunction
Identifies the run function, which has no parameters and no return value.
You can use a job scheduler to invoke the following functions:
schedule (int milliseconds)
Sets a timer immediately for the specified number of milliseconds and causes a subsequent invocation of the run function. The invocation occurs, at earliest, when the timer elapses or when the current function ends, whichever happens last. If you omit milliseconds, the invocation occurs, at earliest, as soon as the current function ends.
repeat (int milliseconds)
Sets a timer immediately for the specified number of milliseconds and then causes repeated invocation of the run function.

The timer is reset each time the run function starts. The rule for each invocation of the run function, including the first, is that the invocation occurs, at earliest, when the timer elapses or when the current function ends, whichever happens last.

cancel()
Cancels later invocations of the job.

The invocation of a run function never interrupts the execution of another function. For example, between the time when a job is scheduled and the time when the invocation of the run function is possible, the user might click a button to cause scheduling of an event handler. In that case, the invocation of the job function waits at least until the event handler invokes its own subordinate functions, if any, and ends.

You can create multiple variables of type JOB and in this way schedule multiple jobs and even invoke the same run function. In all cases, only one function can run at a given time, and it runs to completion.

If you use the same variable to reschedule a job, the previous use of that variable is canceled.