I am working on a SharePoint 2010 integration that has an SPItemEventReceiver for handling ItemAdded and ItemUpdated events for the Document library list. I have added a constructor to handle some initialization for the event receiver. In testing/debugging I have noticed that when my feature is activated (the feature containing this event receiver) my event receiver is initialized 12 times. I have been trying to figure out why the constructor is called 12 times and wondering if all 12 instances are going to be alive until the feature is deactivated or if I need to be careful as some of them may be garbage collected down the road. Anyone know why there are 12 and what their lifetime is?
1
votes
4 Answers
1
votes
I wouldn't say the magic number 12 is relevant; it's just scaling for you. Regardless, SharePoint event receivers should not depend on singleton semantics. What's important is that for each unique event, you can be sure that only one of these event receivers will handle the event, unless you accidentally added 12 to the same list ;-)
-Oisin
0
votes