I am looking for a solution following best practices to simply periodically validate database entries against some business logic. For instance, I have the database with employees, and another table with incoming calls. My service should periodically run the validation task (or tasks, it might be a lot of business rules), which checks if we have missed call(s) for employee in "calls" table and sends a message to assigned employee.

My first thoughts was:

  1. Create some JobManager, which has such methods: "RegisterJob", "UnregisterJob", "ExecuteJob"
  2. Create "JobHandler" which takes job result and decides what to do (e.g. send a message in case missed call found.
  3. Create and implement "IJob" interface, which takes all the logic inside.

But, I think it is some kind of very simple and rough solution. Maybe, there are some better ideas?


1 Answer 1


Write a program that queries the DB and does the things it needs to do. Run it as a scheduled task using the tools provided by the target operating system.

Job done.

Don't write your own scheduler. Don't write your own message queue or "processing engine" or other junk.

Don't clutter it up with IJobSchedulerManagerFactoryMockDataControllerProvider nonsense. If anything beyond the basics are required they will become apparent as you solve the problem at hand. Do that first.

  • Initially it was my plan, but due to requirements, we need to do it using WindowsService only.
    – Alex
    Aug 7, 2017 at 9:39
  • Simple and clear. Windows is full of managing tools that you can handle using .NET. There is no need of rewritting them.
    – MartinS
    Aug 8, 2017 at 12:10
  • @Alex The answer provided is applicable to windows services as well; you use a timer within the service. But watch out for threading issues depending on the timer you use. The advice to stick with something simple is always sound. Expand your design in the future at the point you need that expansion. Aug 10, 2017 at 22:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.