Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to load 100,000 list view items without application freeze?

How to load 100,000 list view items without application freeze?

Scheduled Pinned Locked Moved C#
tutorialquestion
51 Posts 18 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Paw Jershauge

    Thats Easy. just use the listview in virtual mode m8 ;) I have some listviews with over a million entries, and my app dont freeze at all. ;) Just remember to use cached items that also ups the preformance ;) Heres the guideline from MSDN http://msdn.microsoft.com/en-us/library/system.windows.forms.listview.virtualmode.aspx[^] Happy codeing

    With great code, comes great complexity, so keep it simple stupid...:-\ :-\

    C Offline
    C Offline
    Chesnokov Yuriy
    wrote on last edited by
    #24

    you've the right answer while others complaining they can not handle 1000 lines without a bottle of Jack's :laugh: http://www.codeproject.com/Messages/3753678/Re-How-to-load-100-000-list-view-items-without-app.aspx[^] millions of entries, I could not ever dream of that :) I hope virtual view is not so hard of coding...

    Чесноков

    P N 2 Replies Last reply
    0
    • C Chesnokov Yuriy

      Eddy Vluggen wrote:

      ry scrolling 100k items on my machine, locating the entry with the name "Bla400x". You could finish an entire bottle of Jacks' before you even reached the entries that start with a "B".

      :-D honestly, you have to scroll to specific time, and event icons are pretty distinct, and it is very easy to quickly locate minority of error lines with red icons among majority of bluish info events. while scrolling time column is pretty visible as you scroll it. I'm off alcohol :laugh: that enables me to scroll in less than second entire list

      Eddy Vluggen wrote:

      The difference is that it's merely adding a few items every second, and the user will rarely scroll through all the items to locate a particular entry.

      I've just rechecked in Event Viewer events logs, scroll bar is so small that entire list is filled. You can scroll to any place. I do not know it might be some undocumented feature or they are using virtual view.

      Eddy Vluggen wrote:

      rediculous to assume that you're going to read over 500 results,

      I do so always, rather than clicking 50 times to forward to next item, I prefer scroll bar move.

      Чесноков

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #25

      Chesnokov Yuriy wrote:

      and event icons are pretty distinct

      Not if they scroll by at Mach 2.1 :laugh:

      Chesnokov Yuriy wrote:

      and it is very easy to quickly locate minority of error lines with red icons among majority of bluish info events

      I have a checkbox for that - a single click and all you see are ListView items with a red cross :)

      Chesnokov Yuriy wrote:

      while scrolling time column is pretty visible as you scroll it. I'm off alcohol Laugh that enables me to scroll in less than second entire list

      I don't mind scrolling through the event-log, or the log of the profiler, since I'm expecting a list. I wouldn't recommend the same pattern for database-records representing business-objects. But my apologies, you're right, there are circumstances where it might be appropriate :)

      Chesnokov Yuriy wrote:

      I've just rechecked in Event Viewer events logs, scroll bar is so small that entire list is filled. You can scroll to any place. I do not know it might be some undocumented feature or they are using virtual view.

      It's probably not in .NET. Anyway, there should be a virtual-listview example somewhere on MSDN, give it a try.

      Chesnokov Yuriy wrote:

      I do so always, rather than clicking 50 times to forward to next item, I prefer scroll bar move.

      I prefer hitting PgDwn, since it takes effort to move my hand from the keyboard and move it to the mouse. Having "pages" to browse through seems to work for a lot of people, especially if there's a nice index at the bottom. Other people prefer a autocomplete-textbox, or indeed, the scrollbar. Do the Microsoft-thing, and implement 'em all! :cool:

      I are Troll :suss:

      1 Reply Last reply
      0
      • C Chesnokov Yuriy

        Eddy Vluggen wrote:

        ry scrolling 100k items on my machine, locating the entry with the name "Bla400x". You could finish an entire bottle of Jacks' before you even reached the entries that start with a "B".

        :-D honestly, you have to scroll to specific time, and event icons are pretty distinct, and it is very easy to quickly locate minority of error lines with red icons among majority of bluish info events. while scrolling time column is pretty visible as you scroll it. I'm off alcohol :laugh: that enables me to scroll in less than second entire list

        Eddy Vluggen wrote:

        The difference is that it's merely adding a few items every second, and the user will rarely scroll through all the items to locate a particular entry.

        I've just rechecked in Event Viewer events logs, scroll bar is so small that entire list is filled. You can scroll to any place. I do not know it might be some undocumented feature or they are using virtual view.

        Eddy Vluggen wrote:

        rediculous to assume that you're going to read over 500 results,

        I do so always, rather than clicking 50 times to forward to next item, I prefer scroll bar move.

        Чесноков

        N Offline
        N Offline
        Not Active
        wrote on last edited by
        #26

        You have been given the same advice from several people now. Why are you continuing to argue the point? If you don't want to use the advice then don't ask for it.


        I know the language. I've read a book. - _Madmatt

        F 1 Reply Last reply
        0
        • C Chesnokov Yuriy

          you've the right answer while others complaining they can not handle 1000 lines without a bottle of Jack's :laugh: http://www.codeproject.com/Messages/3753678/Re-How-to-load-100-000-list-view-items-without-app.aspx[^] millions of entries, I could not ever dream of that :) I hope virtual view is not so hard of coding...

          Чесноков

          P Offline
          P Offline
          Paw Jershauge
          wrote on last edited by
          #27

          Virtual mode is very easy to use and code... just look at the guidline i gave you from microsoft, it shows you the way. But u need to know that virtual mode has its limits, with what it can do, compared to normal mode. ;)

          With great code, comes great complexity, so keep it simple stupid...:-\ :-\

          C 1 Reply Last reply
          0
          • C Chesnokov Yuriy

            you've the right answer while others complaining they can not handle 1000 lines without a bottle of Jack's :laugh: http://www.codeproject.com/Messages/3753678/Re-How-to-load-100-000-list-view-items-without-app.aspx[^] millions of entries, I could not ever dream of that :) I hope virtual view is not so hard of coding...

            Чесноков

            N Offline
            N Offline
            Not Active
            wrote on last edited by
            #28

            No you missed the point. No one was telling you they couldn't handle it, or that the controls could not support it. They have been telling you it is not a good design. And using the argument that Microsoft does it is not valid. The Event Viewer and such controls are written specifically for high performance situation in C++. You are not doing that are you?


            I know the language. I've read a book. - _Madmatt

            U 1 Reply Last reply
            0
            • L Lost User

              Which is exactly the answer I gave!

              I must get a clever new signature for 2011.

              P Offline
              P Offline
              Paw Jershauge
              wrote on last edited by
              #29

              Didnt see m8, sry ;)

              With great code, comes great complexity, so keep it simple stupid...:-\ :-\

              1 Reply Last reply
              0
              • N Not Active

                No you missed the point. No one was telling you they couldn't handle it, or that the controls could not support it. They have been telling you it is not a good design. And using the argument that Microsoft does it is not valid. The Event Viewer and such controls are written specifically for high performance situation in C++. You are not doing that are you?


                I know the language. I've read a book. - _Madmatt

                U Offline
                U Offline
                User 167261
                wrote on last edited by
                #30

                this entire thread got way too much attention...

                do or do not, there is no try

                C 1 Reply Last reply
                0
                • C Chesnokov Yuriy

                  It is possible to run addition of items in background worker but it needs to add them in report progress handler, main thread only, which also hangs the application. Is there any other approaches to add them to list view without application freeze?

                  Чесноков

                  U Offline
                  U Offline
                  Umbaraumba
                  wrote on last edited by
                  #31

                  The common way is to load items which are currently visible (plus some more for a buffer) and continue loading items on demand as user scrolls the list down.

                  1 Reply Last reply
                  0
                  • C Chesnokov Yuriy

                    It is possible to run addition of items in background worker but it needs to add them in report progress handler, main thread only, which also hangs the application. Is there any other approaches to add them to list view without application freeze?

                    Чесноков

                    V Offline
                    V Offline
                    vsysolts
                    wrote on last edited by
                    #32

                    Preload entries for viewable area and maybe a little around, then load entries only when they should be shown. Cannot specify more concrete, haven't programmed for windows for years. NEVER ever do progress bars for filling controls, this nerves a lot especially if you clicked the wrong control, always use lazy loading. Java AWT is particularly good designed for this approach :)

                    1 Reply Last reply
                    0
                    • C Chesnokov Yuriy

                      It is possible to run addition of items in background worker but it needs to add them in report progress handler, main thread only, which also hangs the application. Is there any other approaches to add them to list view without application freeze?

                      Чесноков

                      R Offline
                      R Offline
                      reshi999
                      wrote on last edited by
                      #33

                      I use the telerik winforms suite for similar operations, because it can :laugh: Telerik gridview

                      1 Reply Last reply
                      0
                      • C Chesnokov Yuriy

                        It is possible to run addition of items in background worker but it needs to add them in report progress handler, main thread only, which also hangs the application. Is there any other approaches to add them to list view without application freeze?

                        Чесноков

                        F Offline
                        F Offline
                        franva
                        wrote on last edited by
                        #34

                        I met the similar problem. Once I wrote a program for retrieving images from a website and I want that users can be notified about the downloading process, so I added a status bar on main GUI, and let the downloading process works on the other thread(let's say B), when it is retrieving the images , the B has to report its status to GUI which is on main thread(let's say A). But B can not access the status bar which belongs to A. So there is a method call BeginInvoke(xxxx); With this method, it enables B to access resourses on A. So I think it should be the answer that you are looking for. Give me reply whatever it works or not :) cheers

                        C 1 Reply Last reply
                        0
                        • F franva

                          I met the similar problem. Once I wrote a program for retrieving images from a website and I want that users can be notified about the downloading process, so I added a status bar on main GUI, and let the downloading process works on the other thread(let's say B), when it is retrieving the images , the B has to report its status to GUI which is on main thread(let's say A). But B can not access the status bar which belongs to A. So there is a method call BeginInvoke(xxxx); With this method, it enables B to access resourses on A. So I think it should be the answer that you are looking for. Give me reply whatever it works or not :) cheers

                          C Offline
                          C Offline
                          Chesnokov Yuriy
                          wrote on last edited by
                          #35

                          You need to use background worker and report the progress with its ReportProgress() function.

                          Чесноков

                          1 Reply Last reply
                          0
                          • P Paw Jershauge

                            Virtual mode is very easy to use and code... just look at the guidline i gave you from microsoft, it shows you the way. But u need to know that virtual mode has its limits, with what it can do, compared to normal mode. ;)

                            With great code, comes great complexity, so keep it simple stupid...:-\ :-\

                            C Offline
                            C Offline
                            Chesnokov Yuriy
                            wrote on last edited by
                            #36

                            Great, thanks, virtual mode is of value to handle large lists especially with large icons. I will use it from now for those purpouses. However I presume I will not be able to use virtual view for log event because the list with those events is not static. There are many threads which use global logger class to report events. They are stored in a queue and once queue limit exceeds some constant 100,000 previous one is dequeued. Log event addition is safe with lock. It is possible that in virtual list view between RetrieveVirtualItem() calls threads may report dozens of new events, queue will move and it will end up of showing the same or odd events several times.

                            Чесноков

                            P 1 Reply Last reply
                            0
                            • U User 167261

                              this entire thread got way too much attention...

                              do or do not, there is no try

                              C Offline
                              C Offline
                              Chesnokov Yuriy
                              wrote on last edited by
                              #37

                              because the topic is a challenge to display 100,000 in as little time as possible, and to find a user who may process them all :)

                              Чесноков

                              1 Reply Last reply
                              0
                              • L Lost User

                                Which is exactly the answer I gave!

                                I must get a clever new signature for 2011.

                                C Offline
                                C Offline
                                Chesnokov Yuriy
                                wrote on last edited by
                                #38

                                can you help with dynamic queue for logs? http://www.codeproject.com/Messages/3754435/Re-How-to-load-100-000-list-view-items-without-app.aspx[^]

                                Чесноков

                                L 1 Reply Last reply
                                0
                                • C Chesnokov Yuriy

                                  It is possible to run addition of items in background worker but it needs to add them in report progress handler, main thread only, which also hangs the application. Is there any other approaches to add them to list view without application freeze?

                                  Чесноков

                                  M Offline
                                  M Offline
                                  Matthew Barnett
                                  wrote on last edited by
                                  #39

                                  Is the code calling BeginUpdate and EndUpdate? It might make a difference, but it's still going to be slow...

                                  C 1 Reply Last reply
                                  0
                                  • M Matthew Barnett

                                    Is the code calling BeginUpdate and EndUpdate? It might make a difference, but it's still going to be slow...

                                    C Offline
                                    C Offline
                                    Chesnokov Yuriy
                                    wrote on last edited by
                                    #40

                                    No, I set the list view Visible to false during events addition. Otherwise the process is very slow.

                                    Чесноков

                                    1 Reply Last reply
                                    0
                                    • C Chesnokov Yuriy

                                      It is possible to run addition of items in background worker but it needs to add them in report progress handler, main thread only, which also hangs the application. Is there any other approaches to add them to list view without application freeze?

                                      Чесноков

                                      L Offline
                                      L Offline
                                      loyal ginger
                                      wrote on last edited by
                                      #41

                                      Thanks for this question. I have an application with the same problem. The answers by some smart folks here are very helpful in solving this problem.

                                      1 Reply Last reply
                                      0
                                      • C Chesnokov Yuriy

                                        can you help with dynamic queue for logs? http://www.codeproject.com/Messages/3754435/Re-How-to-load-100-000-list-view-items-without-app.aspx[^]

                                        Чесноков

                                        L Offline
                                        L Offline
                                        Lost User
                                        wrote on last edited by
                                        #42

                                        Sorry, but this is not something I have ever used. I would suggest you open a new question so others will see it.

                                        I must get a clever new signature for 2011.

                                        1 Reply Last reply
                                        0
                                        • C Chesnokov Yuriy

                                          Dave Kreskowiak wrote:

                                          You have a serious design flaw in your app if you think you need to show 100,000 items in a single control.

                                          Have you ever ran Windows Events on your machine? How many events are there in a list view for a couple of years e.g. windows applications :) It does not freeze as you run it either.

                                          Чесноков

                                          F Offline
                                          F Offline
                                          Fabio Franco
                                          wrote on last edited by
                                          #43

                                          I think you have a complete misunderstanding of how event works. Events happen on demand, when you add 100,000 items all at once, you're simply blocking your application message pump from processing the messages sent by windows (also known as events) and therefore freezing. It's possible to add this 100,000 items in the control without freezing, as already mentioned, by adding in small iteractions and from time to time, allowing the messages to be processed (one simple, but not usually recommended way to do it is call Application.DoEvents()) and thus not freezing the application. In any case, I agree with the guys that 100,000 items in a listview is simply insane. It doesn't make sense, nobody want's to see 100,000 items all at once. One approach I like to take is to display a couple hundred at once at the most and have a textbox filtering the results as you type, very easy for the user.

                                          C 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups