Bad times with TimerExample

I’m trying to use the TimerExample from 2019r3.1 located in /Example Projects/Console. When I attempt to run the example It get the following error:
App.Run, line 4
Timer does not have an event named Run
AddHandler MyTimer.Run, AddressOf TimerAction

I have used timers in GUI apps with no problem but the console thing is new to me and it’s making my head hurt. I this is something that was fixed in a later version I’d apperciate knowing that. Otherwise what am I doing wrong?

Hi @Lewis_Gardner,

Change MyTimer.Run To MyTimer.Action and it should work.

HTH
Wayne

As Wayne says, this should be using the Action event, not the (non-existing) Run event.

FWIW, this example was corrected in 2020r1 if you want to grab the updated version.

Thanks Wayne and Paul!

Run sounded right! Alas it isn’t real… Works like a champ with .Run!

Not knowing that I went all brute force and did this to get a 5 minute timer:

while true
mDoIt
App.DoEvents(300000)
wend

Is there any advantage to using a timer in a console program over App.DoEvents like the above?

The program I’m working on is a Raspberry Pi device to restart an Internet connection when it quits. Every 5 minutes it uses Joost Rongen’s excellent public IP getter routine and if no valid IP then activates a handy power strip to cut power to the modem/router/AP for 30 seconds and hopefully get things back on track. Paul’s GPIO and LCD examples were VERY helpful!

A aside question, Is there an event triggered on a RPi console program that will execute when the program stops? Like stopping via ctrl+c or kill PID? I kinda think not but what do I know…

1 Like

Using App.DoEvents like this will make the app unresponsive for the specified period. Using the timer is a better solution.

For a Console app, if that’s all you’re doing in the Run event, there is no advantage to a timer.

1 Like