By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,996 Members | 1,095 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,996 IT Pros & Developers. It's quick & easy.

Scheduling within a windows service

P: n/a
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 check a
database.

Is there some sort of event/notification API in .net that I can use?

I'm guessing this is a fairly typical requirement

Many thanks for your help

Simon
May 18 '06 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Use a timer
May 18 '06 #2

P: n/a
yes i think timers are the way you want to go. However spend some time
and research them a little. Some are better in certain circumstances
then others. If I remembered which was which I'd tell ya, but it was 2
years ago...

May 18 '06 #3

P: n/a
On 18 May 2006 06:16:31 -0700, "Red2" <sd******@gmail.com> wrote:
yes i think timers are the way you want to go. However spend some time
and research them a little. Some are better in certain circumstances
then others. If I remembered which was which I'd tell ya, but it was 2
years ago...


I couldn't get a timer to work in a service. I put a worker thread in
ran in a loop sleeping for the requisite interval and that worked
fine.

May 18 '06 #4

P: n/a
Imortant:
use System.Timers.Timer
not System.Windows.Forms.Timer
It caught me out

HTH

"Stuart Nathan" <St***********@homecall.co.uk> wrote in message
news:O7**************@TK2MSFTNGP02.phx.gbl...
Use a timer

May 18 '06 #5

P: n/a
On Thu, 18 May 2006 09:25:08 -0400, r norman
<NotMyRealEmail@_comcast.net> wrote:
On 18 May 2006 06:16:31 -0700, "Red2" <sd******@gmail.com> wrote:
yes i think timers are the way you want to go. However spend some time
and research them a little. Some are better in certain circumstances
then others. If I remembered which was which I'd tell ya, but it was 2
years ago...


I couldn't get a timer to work in a service. I put a worker thread in
ran in a loop sleeping for the requisite interval and that worked
fine.

Probably Stuart Irving's comment would have solved my problem.

May 18 '06 #6

P: n/a
Hi Guys,

Thanks for all your comments.

I did think about using timers initially, but I was concerned that they
worked by constantly polling thereby being inefficient.

Is it definately the case that using a timer 24/7 wont be overly
burdensome? I just thought there might be some other way that was more
efficient?

I could quite believe that there isnt - I just really wanted to make
sure before I do anything

Many thanks
Simon
May 18 '06 #7

P: n/a
On Thu, 18 May 2006 16:49:05 +0100, Simon Harvey
<no******@hotmail.com> wrote:
Hi Guys,

Thanks for all your comments.

I did think about using timers initially, but I was concerned that they
worked by constantly polling thereby being inefficient.

Is it definately the case that using a timer 24/7 wont be overly
burdensome? I just thought there might be some other way that was more
efficient?

I could quite believe that there isnt - I just really wanted to make
sure before I do anything

Many thanks
Simon


Neither the timer nor alternative of putting a worker thread into a
sleep loop uses any significant system resources. Neither one uses
CPU time between wake-ups or timeouts. There are two questions. One
is elegance of design and the timer is the proper way to go. The
second is how best to get the job done simply and quickly and my
worker thread did that for me faster than trying to figure out how to
make a timer function properly inside a service.
May 18 '06 #8

P: n/a
Stuart Irving wrote:
Imortant:
use System.Timers.Timer
not System.Windows.Forms.Timer
It caught me out


No, use the System.Threading.Timers. I think these are specifically for
services.
May 18 '06 #9

P: n/a
Timers work just the same in a service or in a desktop application.
They are really simple, as you simply add your coded in the timer.tick or
timer.elapsed event
May 20 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.