I am developing an application in .net. At one point I have to make a function that runs at a fixed time every day. I don't want to use Windows service. Is there any other way that I can make this work?
Asked
Active
Viewed 783 times
3
-
1much better if you can specify what your function does – hallie Jul 12 '10 at 05:00
-
1my function generate xml files for hand held device – Emaad Ali Jul 13 '10 at 11:30
2 Answers
14
I would just use the Windows Task Scheduler (XP, Vista/7). You can also gain access to the Windows Task Scheduler programmatically.

codekaizen
- 26,990
- 7
- 84
- 140
-
1Technically I guess that's a Windows service (though not one you had to write) but +1 since it _is_ the right way to do it. – paxdiablo Jul 12 '10 at 05:13
-
1@paxdiablo: true, though I interpreted that questioner didn't want to _write_ a service to do it. – codekaizen Jul 12 '10 at 05:15
-
@paxdiablo: I don't think tasks in the task scheduler can be seen as Windows Services. Windows Services need to have some criteria before they may be used as service (like a start/stop and installation mechanism) while the taks schedule allows any kind of application to be executed. You can even run winword.exe if you like from the task scheduler. So stating that the taskscheduler is the same as a windows server is not correct. Also the taskschedule can be used by any user while the services can only accessed by a limited set of users. – Gertjan Jul 12 '10 at 05:47
-
-
@Emaad Ali: @dbemerlin is correct, you just need to build an `.exe` and use the task scheduler to schedule and run it. – codekaizen Jul 13 '10 at 11:45
0
Calculate the trigger time as
plannedTime - now
then run your method in a separate thread like here: Run a code in given time interval
You will have to re-schedule the thread for the next after it was run.