Service wake-up each hour

  • Thread starter Thread starter A
  • Start date Start date
A

A

Hello,

I try to make a Windows Service that doing some action at each begin of
hour.
I cannot use the task schedule.
I have try to use thread, timer ... But nothing is correct.

Do you have an ideas to do it ?

Thanks.

Seb
 
A said:
I try to make a Windows Service that doing some action at each
begin of hour.

Have your Service run a loop that periodically checks to see when
it last did anything useful and, if the hour has changed since then,
do the useful thing again, something like

Sub RunProcess()
Dim dtLastRun as DateTime = DateTime.Now()

' Allow a nice tidy shutdown, via the OnStop Event
Do While Not bgServiceStopRequested

If DateTime.Now.Hour <> dtLastRun.Hour Then
dtLastRun = DateTime.Now()
DoRealWork()
End If

Threading.Thread.Sleep( 5000 )
Loop
End Sub

HTH,
Phill W.
 
Thanks a lot for you help
I have found a solution with just one timer and when the timer elapsed, I
calulate the new interval and I set it and it works fine.

Thanks again,
Sébastien
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top