3

I have IIS server which runs few WCF REST services I created. Now I need to add some kind of process that will run on the server and do some work for me once in a while.

I guess the IIS should initiate some kind of a background process or something, but I'm not sure what is the technology I should use in this case?

Ido
  • 951
  • 1
  • 13
  • 27
  • 1
    If you search for "scheduled task" instead of "background process", you'll find dozens of questions on this topic here already. – bzlm Oct 09 '11 at 19:38
  • possible duplicate of [How to set a scheduled task to run in background using Windows Task Scheduler](http://stackoverflow.com/questions/6568736/how-to-set-a-scheduled-task-to-run-in-background-using-windows-task-scheduler) – Joshua Oct 10 '11 at 00:14

4 Answers4

2

After reading at least three other similar questions, it appears the best practice is to avoid running background threads and allow a windows service app to do the processing. You could drop rows into a database table or append a line to a file to start the windows service work.

See any of these threads...

Can I use threads to carry out long-running jobs on IIS?

What are some best practices for managing background threads in IIS?

Community
  • 1
  • 1
Ben Gripka
  • 16,012
  • 6
  • 45
  • 41
1

As an alternative to Windows Task Scheduler, as mentioned by others, you could also:

In your global.asax file, in your application_start() method, you can spin up a new Thread to do whatever you want, and shut it down in the application_end() method.

CodingWithSpike
  • 42,906
  • 18
  • 101
  • 138
0

Check out the window task scheduler

You can schedule a process to come to life and then check to see if any component has queued up work for it to do. The work could be stored in a file (which would need to be locked) or a database table (that's my preference).

Aaron Anodide
  • 16,906
  • 15
  • 62
  • 121
0

Windows Scheduled Tasks would typically be the way to do this.

Doozer Blake
  • 7,677
  • 2
  • 29
  • 40