title: C#: Populating a UI using separate threads
body: <p>I'm trying to make some sense out of an application Ive been handed in order to track down the source of an error. Theres a bit of code (simplified here) which creates four threads which in turn populate list views on the main form. Each method gets data from the database and retrieves graphics from a resource dll in order to directly populate an imagelist and listview.</p>
  
  <p>From what Ive read on here (<a href="https://stackoverflow.com/questions/2302982/a-problem-in-c-using-threads-and-listview">link</a>) updating UI elements from any thread other than the UI thread should not be done, and yet this appears to work? </p>
  
  <pre><code>Thread t0 = new Thread(new ThreadStart(PopulateListView1));
  t0.IsBackground = true;
  t0.Start();
  
  Thread t1 = new Thread(new ThreadStart(PopulateListView2));
  t1.Start();
  
  Thread t2 = new Thread(new ThreadStart(PopulateListView3));
  t2.Start();
  
  Thread t3 = new Thread(new ThreadStart(PopulateListView4));
  t3.Start();
  </code></pre>
  
  <p>The error itself is a System.InvalidOperationException "Image cannot be added to the ImageList." which has me wondering if the above code is linked in some way.</p>
  
  <p>Iis this method of populating the UI recommended and if not what are the possible complications resulting from it?</p>
  
  <p>Update:</p>
  
  <p>I may have given some misinformation by referring to a 'form'. The application is a windows forms application but the code is from a plugin application based on a usercontrol. The threads are created inside an initialise method publically exposed by this control. The listviews etc are also part of this plugin usercontrol.</p>