SPWorkItemJobDefinition class

Serves as the base class for deriving definitions of work-item timer jobs. This class works with the timer job ( SPTimerService) to process work items ( SPWorkItem instances).

Namespace:   Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
<[%$TOPIC/ms439190_en-us_office_15_4_0_0_0_0%]("611573DB-FDED-471e-9249-D899956FBD3F")> _
<[%$TOPIC/ms439190_en-us_office_15_4_0_0_0_1%]([%$TOPIC/ms439190_en-us_office_15_4_0_0_0_2%].LinkDemand, ObjectModel := True)> _
<[%$TOPIC/ms439190_en-us_office_15_4_0_0_0_3%]([%$TOPIC/ms439190_en-us_office_15_4_0_0_0_4%].InheritanceDemand, ObjectModel := True)> _
Public Class SPWorkItemJobDefinition _
	Inherits [%$TOPIC/ms439190_en-us_office_15_4_0_0_0_5%]
Dim instance As SPWorkItemJobDefinition
[[%$TOPIC/ms439190_en-us_office_15_4_0_2_0_1%]([%$TOPIC/ms439190_en-us_office_15_4_0_2_0_2%].LinkDemand, ObjectModel = true)]
[[%$TOPIC/ms439190_en-us_office_15_4_0_2_0_3%]([%$TOPIC/ms439190_en-us_office_15_4_0_2_0_4%].InheritanceDemand, ObjectModel = true)]
public class SPWorkItemJobDefinition : [%$TOPIC/ms439190_en-us_office_15_4_0_2_0_5%]

This class works closely with the SPWorkItem and SPWorkItemCollection classes. You should use the collection class, to which the SPSite object has access, to add work items to the processing queue. When your work-item timer job executes, it pulls work items off the queue in batches that are based on the work item type ( Type). Work items are delivered to the ProcessWorkItems method in cluster ordering, which is specified by using the BatchId.

You must override two methods of this class: WorkItemType and ProcessWorkItems. Note, however, that there are two variants of the ProcessWorkItems method:

It is important to note the LockType value selected for the job definition. (See the SPJobLockType enumeration.)

If the lock type is ContentDatabase, your timer job locks an entire content database ( SPContentDatabase instance) and processes all of the runnable work items in that database (and its site collections) before moving to the next one. In most cases, this is a self-limiting method.

If the lock type is None, you can have multiple front-end computers working against the specified timer job, which provides much greater performance. When you are not using locks on the timer job, the work items themselves (which are self-locking) handle work-item locking. Lock type None is the default value.

LockType value Job provides locks at the level of the timer job and prevents the job from running on more than one computer at a time.

Generally, unless you have a specific and compelling reason to lock an entire content database, it is recommended that you do not use locks (that is, use the default, None).

The difference between the two variants of the ProcessWorkItems method in that the second provides a Boolean parameter, continueProcessing. On job definitions created using this constructor, when the lock type is None, work items continue processing until no work items remain.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.