Sign up ×

I am using the following method when adding items to my ListView.

I've made sure to have the ListView double buffered and tried to optimize everything that I can think of - but no matter what I do the UI is sluggish when adding items rapidly.

I have had this problem for quite some time and scouted around trying to find a solution, but gave up each time because I just wasn't able to fix it. This time I'm hoping to solve this problem. :)

I've though about maybe going with some custom solution? Are there any good ones that can handle "SPEED"? Or is there something I can do with my current code?


private void AddNewItemToListView(string gPR, string rank, string category, string name, string url, string email, string address, string phone, string metadesc, string metakeywords, string mobile, string numbofreviews, string rating, string facebook, string twitter, string googleplus, string linkedin, string sitemap, string siteage, string backlinks, string trafficvalue)
    Invoke(new MethodInvoker(
                string[] row1 = { url, urlSec, address, phone, metadesc, metakeywords, mob, REV, RT, gPR, FB, TW, googleplus, LI, ST, SA, BL, TV };
                ListViewItem item = new ListViewItem();

share|improve this question
Does the speed improve if you change Invoke to BeginInvoke? –  mike z Oct 11 '12 at 16:25

2 Answers 2

up vote 2 down vote accepted

Would you be able to use the ListView.SuspendLayout() method at the start of the work and then call ListView.ResumeLayout() at the finish? That would speed things up alot, I think. You could also try to resume at regular intervals to get some feedback. For instance by inserting the following code at the indicated position:

// Start of work

// Below code inside your delegate


if ((flatListView1.Items.Count % 1000) == 0)
    // Force a refresh of the list
    // Turn it off again

// End of code inside delegate

// Resume layout when adding is finished

share|improve this answer
Wouldent that lock my UI thread? –  Jacqueline Oct 11 '12 at 16:38
No, it would just prevent the ListView from updating its UI at every addition, but instead refresh every 1000 items. –  Daniel Persson Oct 11 '12 at 16:41
This is probably the better solution if it works –  Dharun Oct 11 '12 at 16:46
Oh this works VERY well! –  Jacqueline Oct 11 '12 at 16:47
That's nice to hear! The methods are inherited from System.Windows.Forms.Control, so they're also available on other controls that can contain lots of data, like TreeView, ListBox etc. –  Daniel Persson Oct 11 '12 at 16:51

Instead of directly adding to the UI you can add to a list that slowly gets consumed and added to the UI at x items every second. I've quickly wrote a loose example below but you can read more here:

private BlockingCollection queue;

public void Start() 
    queue = new BlockingCollection<string[]>();
    Task.Factory.StartNew(() => { 
            var item = queue.Take(); 
            //add to listview and control speed 

    //when all items added to queue.


private void AddnewItemToListView(...) 
    var row = ...;
share|improve this answer
Hmm that sounds very smart.. how would i accomplish that in code? –  Jacqueline Oct 11 '12 at 16:19
Make sure you use the ConcurrentBag<T> if are writing to it from multiple threads. –  Magnus Oct 11 '12 at 16:23
@Jacqueline - UI optimization is not a small or insignificant task. You'll probably want to research this topic more thoroughly before asking "how to do it." :) –  JDB Oct 11 '12 at 16:25
@Cyborgx37 year ive come to realize that :) My program runs up-to 500ish threads so UI gets really sluggish when writing to the LW –  Jacqueline Oct 11 '12 at 16:33
@Jacqueline I updated with a very loose example –  Dharun Oct 11 '12 at 16:36

Your Answer


