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

I wonder how should I make a large update in Event Receiver by executing it in other thread. Normally it would look like that:

public override void ItemUpdating(SPItemEventProperties properties)
{
    base.ItemUpdating(properties);

    SPList myList = properties.Web.Lists["myList"];
    SPQuery spQuery = new SPQuery();
    spQuery.Query = "<Where><Eq><FieldRef Name='MyField' LookupId='true' /><Value Type='Lookup'>" + properties.ListItemId + "</Value></Eq></Where>";
    SPListItemCollection itemCollection = myList.GetItems(spQuery);

    foreach(SPListItem item in itemCollection)
    { 
      ...
    }
}

But that "trigger" can affect event 100 000 rows in myList. So what is the best practice to do it, but programmatically, not using Workflows.

I mean something like:

public override void ItemUpdating(SPItemEventProperties properties)
{
    base.ItemUpdating(properties);

    // other "thread"
    UpdateMyList(properties.ListItemId);
}

It would also be nice to know when the taks is completed and give a user a feedback, when he works with the site, changing pages etc

Is that possible at all?

share|improve this question
2  
Can you describe an higher level of your requirement? What are you trying to achieve? What kind of user action would cause such batch update? Can't it be scheduled as a job? –  Steve B Sep 6 '12 at 8:48
    
One list are items with many characteristics, second one contains theirs IDs but also text characteristics which must be adopted to change of the connected item. (reason was that in child list those text could be changed, leaving original data from connected parent ID unchanged) It can not be scheduled, because operators must see results as soon as possible. –  christof Sep 6 '12 at 9:15
add comment

1 Answer

I still think that it should be timerJob; you can add "Processing Status" field to master list to track job progress and use tight schedule, but it will definitely work better than attempt to use async event receiver. just my opinion

share|improve this answer
    
Thanks, good advice I'll search that topic! –  christof Sep 6 '12 at 12:01
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.