1) You can use the Timer class.
When the system starts, check how much time is left until 5pm and set the
timer to fire an event after the calculated interval.
Then, every time the event is fired, configure appropriately the Timer using
the above attitued when you finish processing
2) Your proposal is all right as well, but remember, that you need to start
a new thread in the OnStart method of the system service to perform looping
and checking the time.
--
Cezary Nolewajka
mailto:c.*********************@no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply
"Oleg Ogurok" <ol**@ogurok.com.ihatespammers.ireallydo.co> wrote in message
news:10*************@corp.supernews.com...
Hi all,
I'm trying to write a simple Windows Service that will "do something" at a
given time, for example call a method at 5pm.
What's the easiest way to schedule a task like that in C# ? All I can
think of right now is checking the system clock every minute or so until it hits
5pm, but I feel there has to be a better way.
Note, please don't offer Windows Scheduler. I'm trying to learn here ;)
Thanks in advance,
-Oleg.