Page 1 of 1

TimerEvent issue

Posted: Tue Aug 03, 2010 1:40 pm
by ken chiam
Hi all,
i am implementing a simple timer to check the status of an object every 5 sec. I came across this post, https://forums.jadeworld.com/viewtopic. ... imer#p3565, which mentioned about timer, but i tried and cant mange to get the timer working. the following is how i implemented,

i tried to write a test code in JadeScript:
vars
reg:Register; // a object i have
begin
create reg transient;


beginClassNotification(Register, true,User_Base_Event, Response_Continuous,1);
reg.beginTimer(5000, Timer_Continuous ,1);
end;

in the Register class, i created a timerEvent method, in the method:

timerEvent(eventTag: Integer) updating;

vars

begin
if eventTag=1 then
write 'show me';
endif;
end;

i dont know where goes wrong, please advices. Thanks!

Re: TimerEvent issue

Posted: Tue Aug 03, 2010 1:57 pm
by BeeJay
Ken,

1. The beginClassNotification is somewhat redundant in the context of timer event processing, so unless you have other reasons for having this is your code I would remove it.

2. Trying to test a timer from a JadeScript is probably not a good way to test it as your JadeScript, and therefore your application that registered the timer, will terminate before the timer has the opportunity to fire after the 5 second delay period. Try putting your timer code into say a button click on a simple test form so that your application does not terminate prior to the timer event firing.

Cheers,
BeeJay.

Re: TimerEvent issue

Posted: Tue Aug 03, 2010 2:05 pm
by ken chiam
Hi BeeJay!
Thanks for your reply! u r the guy that i am looking for, the post u posted earlier was where i understand about timerevent. i see.. i will remove the beginnotification. Thanks for your advise! i will try it. :)

Re: TimerEvent issue

Posted: Tue Aug 03, 2010 2:09 pm
by ken chiam
oh, its working! thanks BeeJay!

Re: TimerEvent issue

Posted: Tue Aug 03, 2010 2:13 pm
by BeeJay
It's worth noting that depending on what you're actually trying to achieve there may be better options available to you than using a timer to check the status of an object every 5 seconds.

I was merely indicating in my reply why you were not seeing your timer events firing via a JadeScript, but are getting them when running via an application that doesn't terminate before the timer is due to fire.

Cheers,
BeeJay.