Just an idea: you could set up each event as a separate task scheduled to launch your program with a different command line parameter. Your program could then respond differently, based on this parameter.
Steven Healey , Ondrej Kelle - Be aware that I've recently run into problems with the JEDI task scheduler. It only implements V1.0 of the task scheduler interface. This is deprecated but available in Windows 7. However, it is not available in Windows 8 and will throw an error if you try to create a task.
You could also write a little daemon like program which is started by the windows scheduler at the desired moment. This little program just look if your main app is running. If not it starts it and then sends a message to it. You could also extend this system by writing a process which looks in a data base if there where some events scheduled and then sends messagges at the desired time. You could achieve this with a timer which fires i.e. every our, or every minute if you want to be able to schedule events on a minute base.
In Windows i'd write a service, have it installed together with the program/application and let the two communicate. Kind of the same approach as Klaus suggested.
About Windows Task Scheduler, here's what I've found out: JCL only provides a wrapper (JclTask.pas) to the old API (MsTask.pas) from mstask.dll. Using this old/deprecated API seems to produce runtime errors on Windows 8. The new API is again an automation server, deployed in taskschd.dll. It doesn't seem to register its type library so it's not visible in Delphi's import type library dialog, but you can extract the type library resource from the dll to hard disk and use tlibimp.exe to generate the Delphi import unit.
You could create a task for the Windows task scheduler. JCL has the API translation as well as a wrapper class.
ReplyDeleteThank you Ondrej Kelle .
ReplyDeleteI can see that Windows Task scheduler can be used to call and execute individual programs
What if there was more than one event and the actual event code was embedded in the program ?
You might take a look at http://www.cromis.net/blog/downloads/cron-scheduler/
ReplyDeleteJust an idea: you could set up each event as a separate task scheduled to launch your program with a different command line parameter. Your program could then respond differently, based on this parameter.
ReplyDeleteThank you Ondrej Kelle , I will try that approach :)
ReplyDeleteWelcome Steven Healey , I'm glad to help. :-)
ReplyDeleteThank you Stefan Glienke , I will investigate Cromis too. Downloading the components and demo now
ReplyDeleteSteven Healey , Ondrej Kelle - Be aware that I've recently run into problems with the JEDI task scheduler. It only implements V1.0 of the task scheduler interface. This is deprecated but available in Windows 7. However, it is not available in Windows 8 and will throw an error if you try to create a task.
ReplyDeletePaul Thornton Thanks for the heads-up.
ReplyDeleteYou could also write a little daemon like program which is started by the windows scheduler at the desired moment. This little program just look if your main app is running. If not it starts it and then sends a message to it.
ReplyDeleteYou could also extend this system by writing a process which looks in a data base if there where some events scheduled and then sends messagges at the desired time. You could achieve this with a timer which fires i.e. every our, or every minute if you want to be able to schedule events on a minute base.
Thank you Klaus Edelmann for more good ideas , which is why I love this community :)
ReplyDeleteJust discovered a component from SIcomponents that may help too
ReplyDeletehttp://www.sicomponents.com/taskscheduler.html
Cron on my Linux Server
ReplyDeleteIn Windows i'd write a service, have it installed together with the program/application and let the two communicate. Kind of the same approach as Klaus suggested.
ReplyDeleteAbout Windows Task Scheduler, here's what I've found out: JCL only provides a wrapper (JclTask.pas) to the old API (MsTask.pas) from mstask.dll. Using this old/deprecated API seems to produce runtime errors on Windows 8. The new API is again an automation server, deployed in taskschd.dll. It doesn't seem to register its type library so it's not visible in Delphi's import type library dialog, but you can extract the type library resource from the dll to hard disk and use tlibimp.exe to generate the Delphi import unit.
ReplyDelete