4

I need to schedule windows service on daily basis at pre-defined time to run and then sleep till the next day, How can i do that?

Solution:

Added a timer to timeout every 30 minutes and then validate if the time of the day has reached, if yes then perform the desired function, make sure that, mark a flag once its done for the day.

BT.
  • 505
  • 3
  • 8
  • 16

3 Answers3

14

You don't. You setup a scheduled task; services as (generally) for background running processes.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • Ack. Although you might consider adding a timer if the service *also* should perform periodic tasks (checking for updates, cleaning up work folders or whatever) besides its main purpose. – Dirk Vollmar Mar 04 '10 at 12:30
5

How might I schedule a C# Windows service to perform a task daily

Community
  • 1
  • 1
SwDevMan81
  • 48,814
  • 22
  • 151
  • 184
0

You can start or stop a service using a batch file.

Full details here

Then just add a scheduled task to start or stop the batch file

openshac
  • 4,966
  • 5
  • 46
  • 77