Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Suppose I have a custom timer job that processes work items. How can I check whether the timer job has processed a specific SPWorkItem without interfering with the actual processing?

If I try to initialize an SPWorkItemCollection using SPSite and the work item type's ID, I can get a reference to the work item. But initializing that collection also seems to remove the work item from the queue!

I tried calling SPWorkItemCollection.RevertInProgressWorkItem, but that doesn't seem to do anything. If I reinitialize the SPWorkItemCollection, it doesn't contain my work item anymore.

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

You have to get a subcollection and work on that. Apparently you need to do this to set the parent web. Assuming workItems is your SPWorkItemCollection:

var subWorkItems = workItems.SubCollection(site, web, 0, (uint)workItems.Count);

Now call methods such as RevertInProgressWorkItem on subWorkItems.

I also found that this puts the item back on the queue but with a delivery time 10 minutes in the future. You change this by setting the delivery time explicitly.

Waldek has a good blog post on work item timer jobs.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.