Link to home
Start Free TrialLog in
Avatar of rollocool
rollocool

asked on

MFC - Timers for days and months ?

HI All
     I am working on a module  ( using MFC ) in which my application should alert me after some time interval.That time interval might be in minutes , in hours , in days, in months.What I have done for to achieve this, I set the timer of 30 minutes, And after each 30 mintues I am checking remaining time period, If it reached to 0 ( zero) , then I am firing an event to alert user.
        This is fine if the time interval is in minutes or hours and the application is in system tray.But it might happen that time period will be in days and months.In this case, How can I set the timers for such a long period.Is there any timers for days and months which will fire an event after the specified days.I don't want to do this by comparing system date.

Avatar of akalmani
akalmani

Registry would be of some help but imagine if the system is shutdown there is no way u can keep the timers running..
ASKER CERTIFIED SOLUTION
Avatar of akalmani
akalmani

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I coded some application that does the same thing as an alerter... There, I did this:

When I need to schedule a timer, I calculated the exact alarm time as a CDateTime variable, or in my example an array of variables.. Then I set a timer set to 30 secs.. that will generate one WM_TIMER in every minute.. Then, when WM_TIMER is fired, I walked through my array and checked if any of them is ready to alert..

This solution may help you..

Caner ELCI
Avatar of AndyAinscow
I think you will have to resort to checking the system date at some point.  Maybe you should write the target date/time to the registry (to cope with your app being halted and restarted).
When your app is running then you will need a timer to regularly check how close you are to your target.