1

I want to create a timer job that will be on all of SharePoint's web applications.

It's not a problem - but I'm thinking of the situation when a new web application is created.

Will my timer job be automatically provisioned on that web application as well?

If not, How can I create a timer job that does?

1 Answer 1

1

It's all about in the way you construct your Feature receiver. Simply create a Web Application scoped feature, which is automatically activated (set this in VS already in the Properties window). In this you would put something like that:

SPWebApplication webApp = properties.Feature.Parent as SPWebApplication;

//Add code to check whether it is already added and Remove it 1st.
DeleteJob(webApp.JobDefinitions);

MyJobDefinition myJob = new MyJobDefinition(webApp);

//set schedule and other properties and then run Update 
myJob.Update();

Which constructor you choose is important, because beyond the WebApplication you would also have to consider "where" (on which server it runs - Central Admin by default, or specifically Front Ends..etc., i believe this examples would help http://www.martinhatch.com/2009/08/sharepoint-timer-jobs-and-multiple.html).

Not sure if you've gone through this article, as a comprehensive guide http://www.simple-talk.com/dotnet/.net-tools/a-complete-guide-to-writing-timer-jobs-in-sharepoint-2010/

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.