Jump to content

Scheduled Event


pjama

Recommended Posts

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

Link to comment
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.

Link to comment

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

Link to comment
  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

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.