title: How to add thousands of items to a binded collection without locking GUI
body: <p>I have a setup where potentially thousands of items (think 3000-5000) will be added to an <code>ObservableCollection</code> that is binded to some visual interface. Currently, the process of adding them is quite slow (approx. 4 seconds/1000 items), and of course the GUI is unresponsive during that time. What is a good method to handle moving that many items at once into a collection without worrying about the system locking up? I've looked at <code>DispatcherTimer</code> but I'm not sure if it will provide everything I need it to. </p>
  
  <p>Another question - Is there something I can do to speed up the creation of these objects so that it doesn't take so long to add them to the collection? Currently I use them like so: <code>Collection.Add(new Item(&lt;params&gt;))</code> Would generating the items beforehand, in a background thread probably, decrease the time it takes to add them by a noticeable amount?</p>
  
  <p>Edit: Virtualization is not possible. The requirements specify a <code>WrapPanel</code> look, so the display is actually a <code>ListBox</code> which has a templated ItemsPanel</p>
  
  <p>Edit2: According to the stopwatch, the bottleneck is actually putting items into my <code>ObservableCollection</code>. I will try changing that collection type and doing my own notification to see if that speeds it up substantially.</p>
  
  <p>Edit3: So the answer is in one place - I solved this issue (with help from below) by creating a class which inherits from <code>ObservableCollection</code>. This class did two things - expose a method to add collections at one time, and added the ability to suppress the <code>CollectionChanged</code> Event. With these changes the time it takes to add 3000 items is roughly .4 seconds (97% improvement). <a href="http://peteohanlon.wordpress.com/2008/10/22/bulk-loading-in-observablecollection/">This</a> link details the implementation of these changes.</p>