SharePoint 2010 has many wonderful improvements over previous versions. One of which is a vastly improved Content Deployment mechanism and API.
If your application makes use of Event Receivers or Feature Receivers, these can, depending upon what they do, cause problems during a Content Deployment job. If you have code that you’d rather not execute when your event is triggered as a side effect of a Content Deployment job, you can use the SPImportContext object to find out if a job is running, and if so, to take alternative action.
Here’s an example on an ItemAdding Event Receiver (you’ll also need a using statement referring to the Microsoft.SharePoint.Deployment namespace)
1: /// <summary>
2: /// An item is being added.
3: /// </summary>
4: public override void ItemAdding(SPItemEventProperties properties)
5: {
6: if (!SPImportContext.Current.IsRunning)
7: {
8: //TODO: add event receiver code here
9: base.ItemAdding(properties);
10: }
11: }
If you miss this out this check in an Event Receiver or Feature Receiver, you might cause deadlocks or spurious List Items that you did not intend.