pjama Posted October 26, 2004 Report Share Posted October 26, 2004 I was wondering what the best method to execute a sub-function at scheduled times of the day (ie. 4:00:00 AM and 4:00:00 PM) My program consists of a timed-loop structure counting different machine states, and it needs to log the data to file and restart the count twice daily. The way I have it now, in every loop cycle, it checks if the time = 4:00:00. However, I doubt this is the best way to do it, and I would greatly appreciate any suggestions. -Phil Quote Link to comment
jpdrolet Posted October 26, 2004 Report Share Posted October 26, 2004 I was wondering what the best method to execute a sub-function at scheduled times of the day (ie. 4:00:00 AM and 4:00:00 PM)My program consists of a timed-loop structure counting different machine states, and it needs to log the data to file and restart the count twice daily. The way I have it now, in every loop cycle, it checks if the time = 4:00:00. However, I doubt this is the best way to do it, and I would greatly appreciate any suggestions. -Phil 2472[/snapback] Polling is fine. However, be careful when comparing to exactly 4:00:00 e.g. if the system is busy and the loop only execute at 4:00:01 (skipping 4:00:00) , you'll miss the condition. Maybe time >= 4:00:00 is better. If you do not want to poll, you can have a parallel process generate an event when it is time to log. For example you wait for a dummy notification with the timeout set to expired at 4:00:00. There is no polling and when the wait times out, execute your log. Quote Link to comment
pjama Posted October 26, 2004 Author Report Share Posted October 26, 2004 You can see why I dont want to poll; the exact second could be missed. So far I've put my program as 'Time-Critical' execution. The problem with doing >=4:00:00 is that it would log every second after 4 o'clock, until it reaches midnight again. I'm writing to ask what you meant to "have a parallel process generate an event." How would I go about creating a notification, etc? Thanks, -Phil Quote Link to comment
FLX Posted November 2, 2004 Report Share Posted November 2, 2004 You can see why I dont want to poll; the exact second could be missed. Quote Link to comment
didierj Posted November 8, 2004 Report Share Posted November 8, 2004 So far I've put my program as 'Time-Critical' execution. 2474[/snapback] Even with "Time-Critical" your app isn't proof of missing 4:00:00. The only way to be sure not to miss a time would require you to run a real-time operating system. On Windoze (probably Unix and Mac also) you have always tasks from the system that can have a higher priority than your LV "Time-Critical" process. A temporary high network, Harddisk traffic or complicate screen build up (streaming or rendering) can freeze your computer for several seconds. On W2k/XP systems theese are rare occasions, but if your network switch destroys itself (happend to me: while I was copying big file to a network drive a network switch collapsed, my computer was freezed for more than 15 mins) So far, the best method is the notification method. Didier Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.