473,385 Members | 1,409 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.

Scheduling within a windows service

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
9 1197
Use a timer
May 18 '06 #2
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Attila | last post by:
Hi. I am looking for a site or some coding ideas to run specific subs or programs at certain times and/or dates. For example, I would like to automate pulling data via ADO(.NET) at 6 am, on...
6
by: Tony Proctor | last post by:
Hi everyone We're experiencing some serious anomalies with the scheduling of ASP threads. I'd be interested to hear if anyone knows what algorithm is used (e.g. simple round-robin, or something...
3
by: mirek | last post by:
Hello, My ASP.NET application must have additional functionality which isn't typical for ordinary web use. It is: - connecting to the other server using specified protocol (an option to...
2
by: Randall Powell | last post by:
I am in the process of developing a Windows Service which will: (1) monitor multiple network shares; (2) marshal text file transfers into an SQL Server 2000 instance; and (3) provide messaging...
1
by: Majed | last post by:
hi I'm planing to make scheduling app and need your advice on the best way to do that,and how to save the tasks to be executed and retrive their data at the right time. your input will be highly...
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: archana | last post by:
Hi all, I want to develop one windows service in which i want to provide some scheduling facility. What i want is to take start time frm one xml file and then at that specified start time. ...
4
by: Dinsdale | last post by:
I'm looking at adding scheduling features to an application and I wanted to ask the community about any experience with scheduling components, either open source like from code project or from a...
5
by: Jeff | last post by:
Hey ..NET 2.0 I'm working on a winservice created in .NET 2.0. Now I want to do some modications to this winservice. I want this winservice at every start of a new month to start a thread...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.