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).
Inheritance Hierarchy
System.Object
Microsoft.SharePoint.Administration.SPAutoSerializingObject
Microsoft.SharePoint.Administration.SPPersistedObject
Microsoft.SharePoint.Administration.SPJobDefinition
Microsoft.SharePoint.Administration.SPPausableJobDefinition
Microsoft.SharePoint.Administration.SPWorkItemJobDefinition
Namespace: Microsoft.SharePoint.Administration
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
Syntax
'Declaration
<GuidAttribute("611573DB-FDED-471e-9249-D899956FBD3F")> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public Class SPWorkItemJobDefinition _
Inherits SPPausableJobDefinition
'Usage
Dim instance As SPWorkItemJobDefinition
[GuidAttribute("611573DB-FDED-471e-9249-D899956FBD3F")]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public class SPWorkItemJobDefinition : SPPausableJobDefinition
Remarks
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.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also
Reference
SPWorkItemJobDefinition Members
Microsoft.SharePoint.Administration Namespace
Microsoft.SharePoint.Administration.SPTimerService
Microsoft.SharePoint.SPWorkItem
Microsoft.SharePoint.SPWorkItemCollection
Microsoft.SharePoint.Administration.SPJobLockType