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?
+13
A:
I would just use the Windows Task Scheduler (XP, Vista/7). You can also gain access to the Windows Task Scheduler programmatically.
codekaizen
2010-07-12 05:00:33
Technically 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
2010-07-12 05:13:54
@paxdiablo: true, though I interpreted that questioner didn't want to _write_ a service to do it.
codekaizen
2010-07-12 05:15:18
@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
2010-07-12 05:47:42
i am developing application in .net.
Emaad Ali
2010-07-13 11:38:28
@Emaad Ali: So? You write a Program and the task scheduler runs it...
dbemerlin
2010-07-13 11:41:46
@Emaad Ali: @dbemerlin is correct, you just need to build an `.exe` and use the task scheduler to schedule and run it.
codekaizen
2010-07-13 11:45:15
A:
Calculate the trigger time as
plannedTime - now
then run your method in a separate thread like here: http://stackoverflow.com/questions/1972964/run-a-code-in-given-time-interval
You will have to re-schedule the thread for the next after it was run.
mar10
2010-07-12 05:41:25