Home Notices Documents Classes Download Others Rice
Classes  >  timer  >  timer(class,string,int)
timer class : timer(class,string,int) fitter

Description

Return an instance of the timer class that is initialized by the specified value.

Syntax

new timer(class handleInstance, string signature, int interval)

Arguments

ClassNameDescription
classhandleInstanceAn instance of the user-defined class that has the handler.
stringsignatureSignature of the handler that is defined in the handleInstance.
intintervalTime span.

Return value

ClassDescription
timerA timer class instance that was initialized.

Sample code

Suppose you have the following class definition.

1:

class handle

2:

...

3:

open fitter handle()

4:

// any initialization code...

5:

endfitter

6:

...

7:

open method void timerHandler(timer t)

8:

// any handling code....

9:

endmethod

10:

...

11:

endclass

Usage of the timer(class,string,int) fitter is as follows.

1:

handle h = new handle();

2:

timer t = new timer(h,"timerHandler(timer)", 1000);

Notes

The first argument is an instance of any user defined type. It must have the method that you want to run in the timer.

The second argument is a string that indicates the signature of the timer handler.

The timer handler must be open method, and must have a timer class argument.

The return value from a handler will allow any type. However, the return value is not used. I recommends that a handler do not return a value.

In other words, the handler should be have the following format.


open method handlerName(timer agumentName)

// Please do here the necessary processing.

endmethod


If you want to specify this method in the second argument. It will specify as "handlerName(timer)".

The third argument is the specified time interval. This argument is int class. You should be specified in the milliseconds unit. Zero or less cannot be specified.

Links for reference

Copyright © Rice All rights reserved.