For Programmers: Free Programming Magazines  


Home > Archive > C# > April 2006 > windows service









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author windows service
vndaxanh@yahoo.com

2006-04-26, 7:03 pm

Hi, I'm new to writing .net windows services (or windows services
altogether). I need to write a windows service that runs a piece of
code everynight at 1am. Eventually, we would need this service to run
a piece of code every x minutes past 1am, or something similar. Right
now, I have it on a timer that executes every minute. This needs to
change to once a day at 1am. Any help is appreciated!

protected override void OnStart(string[] args)
{
System.Timers.Timer aTimer = new System.Timers.Timer();
aTimer.Elapsed += new ElapsedEventHandler(ExecuteJobs);
// Set the Interval
aTimer.Interval = 60000;
aTimer.Enabled = true;
}

private void ExecuteJobs()
{
// do something here
}

Hanna

John Fullmer

2006-04-27, 7:03 pm

Unless you want to tell the service to check for the time before it
tries to run... you may want to consider scripting a call to kick off
the process from a job in DTS with SQL Server, or just create it as an
exe and schedule it.

- John Fullmer

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com