The best Timer Job is a dumb Timer Job!

I have completed several projects using SharePoint Timer Jobs and for each project I am reminded how Timer Jobs can be a pain to implement and test. Yet they are often necessary to meet the requirements of the application. Here is what I have learned regarding Timer Jobs. Make them stupid! Rather than creating timer jobs that DO things, create Timer Jobs that simply tell something else to do the work.

Imagine that you use Microsoft Outlook to keep track of your meetings and tasks. You want to be reminded when you have something that needs to be done. This reminder comes to you on a specific schedule. When the reminder executes it does not do the work for you (if it does please let me know how you pulled that off), it simply tells you that something needs to be done. Your Timer Job can be the same way. It simply executes at a scheduled time and tells something else to do the work.

The next time you build a custom Time Job, try extracting the logic into another service that does the heavy lifting. This could be implemented as a workflow, a stored procedure or perhaps a custom web service. By taking the code out of the Timer Job, you can now update and debug your code independently, execute your code at your convenience, and you may even be able to reuse your code for other purposes.

I hope this tip helps someone else save time and frustration as it did for me.