multithreading - C# Background Worker UI Update -
To get a large amount of data from the database without stopping the main thread, I try to use a background worker I am here. It works well, except that when it comes to updating the UI, the update will freeze the screen. The related code is as follows:
Private Zero contains bw_RunWorker (Object Sender, RunWorkerCompletedEventArgs e) {lvwTest.BegginUpdate (); LvwTest.Items.Clear (); // UI foreach to population (test data in test data) {ListViewItem lvi = lvwTest.Items.Add (ti.Value1); Lvi.SubItems.Add (ti.Value2); } LvwTest.EndUpdate (); }
The update takes approximately 2 to 3 seconds, for which the screen is locked. I know that only the main thread can update the screen, but is it possible to load this data in memory somehow (any other example in the background thread or any other list) and then display it? What I want to do is to program the program to refresh the data while not taking time in the main thread.
I want to load data in memory and use virtual mode listview
I recommend. In this way, you only create ListViewItem
objects because they are necessary.
Comments
Post a Comment