![]() |
How to use of the timerYou can execute the procedure after an interval or in cycles.
How to execute the procedure after an intervalAt first, prepare the procedure to execute, and register it to the timer as trigger driven.
#include "WSDtimer.h" //the procedure which is executed by the timer ( trigger driven ) void triggerHandler(unsigned char clock,void* data){ //The parameter: data is the third parameter of the method: addTriggerProc(). //To do: } void event_procedure(WSCbase* obj){ //this parameter is passed to the procedure. void* data = (void*)1234; //add the procedure to the timer (trigger driven) //after 1000ms long id = WSGIappTimer()->addTriggerProc( triggerHandler,WS1000MS,data ); ... //if cancel... WSGIappTimer()->delTriggerProc( id ); }You can implements the procedure which you want in "triggerHandler()", and pass some data by the third parameter:void* of WSDtimer::addTriggerProc(). WSDtimer::addTriggerProc() returns a timer id. you can cancel the timer by the id with WSDtimer::delTriggerProc(). Notice: After executing the procedure, it do not update the instances automatically, so you have to do it if needs. //a sample of the trigger procedure. void timerHandler(unsigned char clock,void* data){ WSCbase* object = (WSCbase*)data; object->setProperty(WSNlabelString,"hello."); object->update(); //update the instance. } How to execute the procedure after in cyclesAt first, prepare the procedure to execute, and register it to the timer as cycle driven.
#include "WSDtimer.h" //the procedure which is executed by the timer ( cycle driven ) void timerHandler(unsigned char clock,void* data){ //clock is a counter of the interval of 250ms //The parameter: data is the third parameter of the method: addTimerProc(). //To do: } void event_procedure(WSCbase* obj){ //this parameter is passed to the procedure. void* data = (void*)1234; //add the procedure to the timer (cycle driven) //500ms interval long id = WSGIappTimer()->addTimerProc( timerHandler,WS500MS,data ); .. //if cancel.. WSGIappTimer()->delTimerProc( id ); }You can implements the procedure which you want in "timerHandler()", and pass some data by the third parameter:void* of WSDtimer::addTimerProc(). WSDtimer::addTimerProc() returns a timer id. you can cancel the timer by the id with WSDtimer::delTimerProc(). Notice: After executing the procedure, it do not update the instances automatically, so you have to do it if needs. The cycles: WS250MS,WS500MS,WS750,WS1000MS,WS1250MS,... (250ms interval) //a sample of the timer procedure. void timerHandler(unsigned char clock,void* data){ WSCbase* object = (WSCbase*)data; object->setProperty(WSNlabelString,"Hello!"); object->update(); //udpate the instance } Document Release 3.0 For Use with Wide Studio Release 3.0, Summer 2002
|