Saturday, October 3, 2009

One time scheduled timer job

Scenario:
Creating a onetime scheduled timer job.

Solution:
SPSchedule abstract class support other schedule options including SPOneTimeSchedule.

The one-time scheduled job is run during the next available time that meets the filter criteria. For example, if only the starting and ending seconds are set, the job runs during the next minute at a random point between the starting and ending seconds. If the starting second/ending second is set to 0/30 and the starting hour/ending hour is set to 22/23, the job starts between 11:00:00 P.M. and 11:00:30 P.M.

Code:

// Create a one time job and run it.
SPOneTimeSchedule oneTimeSchedule = new SPOneTimeSchedule(DateTime.Now);

// Get a new instance of your Timer class with proper constructor parameters
CustomSiteCreationJob newJob = new CustomSiteCreationJob("Job One Time", webApplication);

newJob.Schedule = oneTimeSchedule;
newJob.Update();
Article:
SPOneTimeSchedule , Writing a timer job

1 comments:

Anonymous,  January 23, 2013 at 6:55 AM  

thank you very much :)