Sign in Join
Wiki copytemporary

LongTimer: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11# Summary
22
33- TLongTimer is a descendant of TIdleTimer, and keeps all of its properties and methods except the Interval property
44- The interval has been changed into a set of additional properties, that allow for very long intervals - Daily, Weekly and Monthly
55- The intended use is for TrayIcon applications or services like alarms, updaters or notifiers
66
7-<figure>
8-<img src="sc_longtimer.png" title="sc_longtimer.png" />
9-<figcaption>sc_longtimer.png</figcaption>
10-</figure>
7+![](/wiki-images/7/7f/Sc_longtimer.png)
118
129# Download
1310
1411Download from the [Lazarus CCR here](https://sourceforge.net/p/lazarus-ccr/svn/HEAD/tree/components/longtimer/)
1512
1613# Installation
1714
1815- Download the 'longtimer' package from the Lazarus CCR repository and copy the folder to a folder off your lazarus components folder
1916- Install the package (open it, Compile then Install it) and TLongTimer will appear on your 'System' components tab
2017- Drop onto a form, set properties and you are good to go
2118- Opening the demo application will give you a good idea how to set the additional properties and use the component
2219
2320# License
2421
2522- LGPLv2
2623
2724# Support
2825
2926- minesadorada on the Freepascal.org forum
3027- Updates will go to the CCR repository when available
3128
3229# Tips
3330
3431- Initially, AutoEnabled=False, so TLongTimer will act much as a regular timer
3532- The enumerated properties IntervalType, SampleInterval and WeeklyDay are displayed in the 'correct' order, and you can set them via code by TypeCasting if you don't want to use the lt type literals.
3633
3734eg.
3835
3936``` pascal
4037LongTimer1.WeeklyDay:=TDay(1); // sets the Weekly Day to Tuesday (2nd in the list)
4138LongTimer1.SampleInterval:=TSampleInterval(1); // sets the interval sample rate to every 5 minutes (2nd in the list)
4239LongTimer1.IntervalType:=TIntervalType(1); // sets the interval type to to Weekly (2nd in the list)
4340```
4441
4542\- this is exactly equivalent to:
4643
4744``` pascal
4845LongTimer1.WeeklyDay:=lt2Tuesday�; // sets the Weekly Day to Tuesday
4946LongTimer1.SampleInterval:=lt2Every5minutes�; // sets the interval sample rate to every 5 minutes
5047LongTimer1.IntervalType:=lt2Weekly�; // sets the interval type to to Weekly
5148```
5249
5350- Every time an interval property is changed, the Timer is temporarily suspended if it is already running
5451- Number of days in a month is automatically catered for. If you set the MonthlyDate to 31 for instance, in Sept, Apr Jun, Nov it will fire on day 30, and on the last day of February (according to Leap Year)
5552- The SampleInterval property determines the trade-off between CPU use and accuracy. EveryMinute is the most accurate, but checks the time/date etc every minute so uses more CPU than Every45minutes. However, when Sample interval is Every45Minutes,the IntervalType is ltDaily and the time is set to 2pm, the event could fire as late as 2:45 (which may be an acceptable option)
5653- If you set AutoEnabled to TRUE then the timer will switch on and off according to Idle status, and could use significant CPU time. Note: This could be desired behaviour if you want to be sure LongTimer won't be working when some time-critical operation in your application is in progress. (This is why TLongTimer was descended from TIdleTimer rather than TTimer)
5754- You can change SampleInterval and the Interval properties whilst LongTimer is running and it will update
5855- The event OnSample is fired according to SampleInterval property
5956
60-\
6157---- Demo application for TLongTimer
6258
63-<figure>
64-<img src="sc_longtimerdemo.png" title="sc_longtimerdemo.png" />
65-<figcaption>sc_longtimerdemo.png</figcaption>
66-</figure>
59+![](/wiki-images/b/b6/Sc_longtimerdemo.png)
6760
6861---
6962*From the Free Pascal wiki, page "LongTimer", as it stood on 2020-02-19 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
7063Category: Components
7164Category: Lazarus-CCR

Back to history