Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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)
[GuidAttribute("611573DB-FDED-471e-9249-D899956FBD3F")]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public class SPWorkItemJobDefinition : SPPausableJobDefinition

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.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.