I am trying to use a background worker to extract a large amount of data from a database without stopping the main stream. This seems to work well, except when it comes to updating the user interface, the update freezes the screen. The corresponding code is as follows:
private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
lvwTest.BeginUpdate();
lvwTest.Items.Clear();
foreach (TestItem ti in testData)
{
ListViewItem lvi = lvwTest.Items.Add(ti.Value1);
lvi.SubItems.Add(ti.Value2);
}
lvwTest.EndUpdate();
}
The update takes about 2 to 3 seconds, for which the screen is locked. I understand that only the main thread can update the screen, but is it possible to somehow load this data into memory (in the background thread or another instance of the list or something else) and then just display it? All I want to do is just update the data without taking up time in the main thread.