473,385 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Service wake-up each hour

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
Nov 21 '05 #1
3 1883
You mean that you want to use the system.timers.timer event and than see if
the full hour is reached based on 'Now"..

The first time go to it by going down and after the first time the timer can
be set to an hour and than everytime adjusted based on the exact 'Now'.

Be aware that there are 4 timers and that you cannot use the forms timer for
this.

http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps,

Cor
Nov 21 '05 #2
"A" <A@A.COM> wrote in message news:di**********@s1.news.oleane.net...
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.
Nov 21 '05 #3
A
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

"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> a écrit dans le message de news:
di**********@yarrow.open.ac.uk...
"A" <A@A.COM> wrote in message news:di**********@s1.news.oleane.net...
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.

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: rbt | last post by:
I have a win32 service written in Python. It works well. It sends a report of the status of the machine via email periodically. The one problem I have is this... while trying to send an email, the...
9
by: Hardy Wang | last post by:
Hi all: I read an article from http://www.c-sharpcorner.com/Code/2003/Sept/InstallingWinServiceProgrammatically.asp about how to install a windows service programmatically. Based ont the code...
23
by: Adam Clauss | last post by:
I have a C# Windows Service running as the NetworkService account because it needs to access a network share. As part of the service's initialization, I want the service to terminate, if an...
6
by: Leonardo Curros | last post by:
Hello, I would like to know what's the best way to restart one service. I would like to do it from the service itself. Is this possible? I try it with ServiceController.stop()...
6
by: diffuser78 | last post by:
I am using 8 computers on a small network. I have one Main computer which should be able to remotely start other computers. I used Wake on LAN to start them all. My Main computer is Linux. ...
9
by: Simon Harvey | last post by:
Hi all, Can anyone point me in the direction of how to have a .net developed service wake up every sof often to perform a task. I need to make a service that will wake up every 15 mins to...
4
by: cmgarcia17 | last post by:
I have two windows services that I've written: the first is a "Listener Service" that listens for MSMQ Message delivery. The second is a "Watcher Service" that monitors the state of the first. If...
1
by: Oscar | last post by:
Hi, Is there a way to to "wake" a win xp machine from screen power save using c#? I got a computer that turns off the screen after a while and i'm programming an app that reads smart cards and...
0
by: taysk8 | last post by:
So ya... I'd like to write a simple program in Java for scheduled wake-on-lan and shutdown over lan of any lan-enabled computer, regardless of O/S. School systems and library systems really need...
20
by: =?Utf-8?B?cmtibmFpcg==?= | last post by:
I was executing the steps given in http://suppor.microsoft.com/kb/308359 for testing a sample web service application. However, the following line gives a compilation error: localhost.Service1...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.