Home
Mergeable Cell Listbox
StyledLine
Ultimate Slider
Persistent Timer



Simple free open source timer classes

Download Persistent Timer Classes


This project contains 2 timer subclasses from the classic framework. They allow you to create a start and forget timer that you don't need to keep a reference, and you can do that without leaking memory.

One class provides the same functionality as Xojo.Core.CallLater and CancelCall. It  brings the same functionality to the classic framework for use in desktop and Web apps. This allows you to maintain projects and add features in old versions of Xojo and RealStudio in way that will make it simpler to eventually convert it to the new framwork

The second timer subclass class also provides start and forget functionality but is more flexible and supports multi-shot (ModeMutiple) as well as single-shot timers. That flexibility means it can be instantiated and called in several ways… In addition for multi-shot timers if you don’t turn it off in the action event, it will keep going until the app shuts down

Timers are useful for many things in REALStudio/Xojo besides the obvious. Often timers are the easiest way to work around limitations or bugs. For that the most common usage is single use (ModeSingle) timers. It is often convenient to instantiate them in code using or AddHandler or a Timer Subclass

Often once you start a timer you don’t need to do anything else with it, particularly for workarounds… However because of how RS/Xojo manages memory, you if you don’t keep a reference, once the calling methods exits, the timer will never fire as Xojo/RS will destroy it, thinking it is no longer needed.

When you drag a timer onto a Window, you don’t need to worry about that as the Window will keep a reference to it. However when you instantiate it in code, you are responsible for keeping a reference to it and you are responsible for setting the reference to nil if needed when you are done with it.

Often this is just bookkeeping that serves useful no purpose in the logic of what you are trying to accomplish and adds needlessly to a long list of properties. This makes code maintenance more of a chore than it needs to be.

Ideally a timer should keep running even if there are no saved references, and when stopped, if there are no saved references it is should destroyed automatically. This would encapsulate more of the timer management in the timer itself and so is one less thing you have to worry about.

For single shot timers this type of functionality is handled in the new Framework by Xojo.Core.Timer.CallLater. That method is only available in 2014.r3 +. The SingleActionTimer class adds that functionality to older versions

The PersistentTimer class included here is more flexible than CallLater in that you can use a multi-shot (ModeMultiple) Timer. This class may be instantiated in different ways. The action may be assigned by AddHandler or adding a delegate to a property. It has a tag property to pass parameters to the action, and it may also be subclassed