Timer class oddness

I created a class Clock with Timer as its Super
Added an Action Event to the class and simply added ‘Beep’ in the action event.

Now doing this:

var t as new Clock
t.Enabled= true // not needed I guess
t.Period = 1000
t.RunMode = Timer.RunModes.Multiple

And the timer does not start. But it should, not?

Of cours it works when I add Clock class to the Window. But it should work without adding it into a window, I think.

You need to add a handler for when the timer runs down. Otherwise no event fires. Like:

AddHandler t.Action, WeakAddressOf myClockHandler

It looks like you’ve put this into a local property that goes out of scope when the function ends. In other words, your Timer doesn’t live long enough to actually fire.

Assign it to some persistent property, like a Window property or a Module, instead.