views:

106

answers:

3

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
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
@paxdiablo: true, though I interpreted that questioner didn't want to _write_ a service to do it.
codekaizen
@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
i am developing application in .net.
Emaad Ali
@Emaad Ali: So? You write a Program and the task scheduler runs it...
dbemerlin
@Emaad Ali: @dbemerlin is correct, you just need to build an `.exe` and use the task scheduler to schedule and run it.
codekaizen
A: 

As a service, you can use CRONw.

For a non service (that runs as a process) you can use nnCron. It is very small, and has a large range of features, which are listed nicely on the front page of the link provided.

Coltin
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