0

I am not seeing any good options other than using windows services to invoke a method() to run periodically.

Any suggestions?

3Dave
  • 28,657
  • 18
  • 88
  • 151
  • In enterprise SaaS organizations I think it's fairly common to have a scheduling service to handle these types of tasks. Your question is too broad to give a specific answer. There are so many ways to solve this problem. If you build your application as a Windows Service it will always be running and you could make it so that the main is just a loop with a big sleep followed by a call to the code you want to execute. That's the easiest solution, it's also the worst. – evanmcdonnal Sep 12 '13 at 23:14
  • @evanmcdonnal You'd probably want to start a timer with a callback if doing it in a service. Using `Thread.Sleep(foreverInMs)` can cause problems. – 3Dave Sep 12 '13 at 23:18

1 Answers1

1

You can add a script (or executable) to the Windows task scheduler. This is available in Control Panel and is labeled either "Task Scheduler" or "Scheduled Tasks" depending on what version of Windows you're running.

Some things are better implemented in services, but the task scheduler suffices for anything that doesn't have to run super-frequently.

For Win7 (or Server 2008), see http://windows.microsoft.com/en-us/windows7/schedule-a-task

Also, see this answer for more information.

Update

If you only need to call a web service, and don't care much about the result, you can use curl or wget via the task scheduler.

Community
  • 1
  • 1
3Dave
  • 28,657
  • 18
  • 88
  • 151
  • Thank you David. Are there any other options to do this other than the Task scheduler and the Windows service? My code is a simple c# code which calls a REST service. I have to host this c# code somewhere so that it could run periodically. – user2773547 Sep 12 '13 at 23:59
  • @user2773547 I'm not sure I understand the difficulty. Put your code in a C# console app, and add it to the task scheduler. Is there some other requirement that makes this untenable? – 3Dave Sep 13 '13 at 14:48