How to get a delphi application (that's running) to do something at a particular time/date
delphi
Solution
You can use my CRON compliant Cromis Scheduler (link to archive.org). It even supports some things that cron does not. Interval based events for instance and from / to timeframe. I use it in a lot of my software and it has proven itself quite useful. It is free, very lightweight, works in threads and is production tested. If you need any further help just mail me.
The other ways would be:
- Use windows scheduling API as already suggested. But this may change between OS-es.
- Use JCL that has a scheduler unit (component in the JVCL), but I found that one hard to use from code directly. That is why I wrote my own.
Problem
My application sits in the system tray when it's not being used. The user can configure events to occur at particular schedule. For example they may way the task performed mon-fri at 5pm or every wednesday at 3pm or on the 16th of every month at 10am. Assuming my delphi program is always running, it starts at boot-up, what is the best way in delphi to support the triggering of these scheduled events. Obviously a TTimer can be used to schedule events based on elapsed time but they don't seem suited to this problem. Cheers