Timer from code not working?

Spent the last 35 minutes searching, and what I’ve got matches everything I can find about setting up a timer via code.

[code] dim resetStatusTimer as new Timer

resetStatusTimer.period = 100
resetStatusTimer.mode = timer.ModeMultiple
resetStatusTimer.enabled = true

AddHandler resetStatusTimer.Action, AddressOf resetStatus

[/code]
The period is so short because I don’t even care about waiting at this point, I want the timer to work first…

Notes: I’ve confirmed the resetStatus method works.

Thoughts? Ideas?

I’m betting the timer goes out of scope and is destroyed before it can fire

I have a class to handle that:

http://katkosoft.xojonews.com/Persistant%20Timer/PersistantTimer.html

I believe that Jim’s correct. What if you move the AddHandler call to below the Dim line and change the period to 2?

[quote=154299:@Tim Parnell]Spent the last 35 minutes searching, and what I’ve got matches everything I can find about setting up a timer via code.

[code] dim resetStatusTimer as new Timer

resetStatusTimer.period = 100
resetStatusTimer.mode = timer.ModeMultiple
resetStatusTimer.enabled = true

AddHandler resetStatusTimer.Action, AddressOf resetStatus

[/code]
The period is so short because I don’t even care about waiting at this point, I want the timer to work first…

Notes: I’ve confirmed the resetStatus method works.

Thoughts? Ideas?[/quote]

  • Make ResetStatusTimer a module or window Timer property
  • Modify the first line of your code :
resetStatusTimer = new Timer