Search code examples
.netwindows-servicesserviceappfabricworker

Implementing worker service in .NET


I need to add a "worker process" to my current solution with the following requirements:

  • must run continuously (or at specific intervals)
  • auto start
  • get data from several sources (SQL database, WCF services,...) and make a series of calculations
  • make decisions based on those results and perform some actions (persist some results, send notifications,...)
  • it should have public service operations to allow interaction (request to reprocess data from a particular day, for instance)

I will create it as a .NET class library, so I can take advantage of the other assemblies in my solution.
It will be deployed in an enterprise environment and I have total access to the servers.

What hosting option would you take?

  • Windows Service
  • WCF Service in IIS with Windows Server AppFabric (allows auto start)
  • Other option?

Solution

  • I had almost the exact same problem, I chose a Windows Service that programatically launched a WCF Service so it could communicate with my main application, and it's working pretty good. I even added extra logic. I could design my worker's tasks and load them with MEF on my worker, so the worker didn't even know what executes, he just launches tasks with parameters, and retrieves status information, and returns execution results.