List instance data is deployed asynchronously

Suppose you have SharePoint list instance that is deployed to site using feature. Also suppose this list instance has event receiver bound to it. Add some debug messages to event receiver, run your project and activate feature through SharePoint web interface. From output you should see that items are added to list on more than one thread.

Example data

I have unique values for one field and these values are hierarchical. Example of values is here:


There are about 250 rows of data defined in list instance definition.

Asynchronous creation of list items

When I run my SharePoint solution using Visual Studio 2010 and activate list instance feature through web interface then I can see the following about in Visual Studio debug window:

Asynchronous creation of list items

Note the random order of ID-s – in list instance definition rows are ordered correctly. Also note that there are threads with different ID-s that are closed when data is inserted.

Feature is activated before items are inserted

One interesting thing I also noticed is that feature is activated and browser is already returned to features page but inserts still continue. I faced some situations when data gets fully inserted about one minute after activating the feature.

You should very carefully handle situations where you have event receiver bound to automatically filled list and your receiver expects full data to be already there. Also you should be careful when your receiver expects that data is inserted in same order as it appears in list instance definition.

See also

Leave a Reply

Your email address will not be published. Required fields are marked *