C# - updating label while adding items to ListView
<p>I have a ListView which I populate with a lot of items, over 3000. This can take up to 15 seconds.
Every time I add an item I want to update a label stating how many items have been added so far.
To do so I use this code:</p>

<pre><code>foreach (FileInfo f in dir.GetFiles("*.*", SearchOption.AllDirectories))
{
    DateTime dt = GetDateTakenFromImage(Path.Combine(f.Directory.ToString(), f.Name));
    count++;
    labelLoadedLeft.Text = "Loading " + count + " files so far";
    ListViewItem lSingleItem = lv.Items.Add(f.Name);

    lSingleItem.SubItems.Add(dt.ToString("dd MMMM yyyy"));
    lSingleItem.Tag = Path.Combine(f.Directory.ToString(), f.Name);
}
</code></pre>

<p>Unfortunately the label does not show until all items have been loaded.</p>

<p>I understand this has to do with the fact that I am doing a lengthy operation on thr UI thread and that I should probably be using a backgroundworker to do the work.</p>

<p>Does anyone know of good and simple examples on how to use background worker. What I have found so far is too complicated for me or too convoluted.</p>

<p>Thank you</p>

<p>Crouz</p>
