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. using thread for listview update

using thread for listview update

Scheduled Pinned Locked Moved C#
helpquestionannouncement
5 Posts 5 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 Offline
    P Offline
    prasadbuddhika
    wrote on last edited by
    #1

    in my app i've two threads , one for update the listview and one for main form,the problem is i used thread.sleep() method to update the listview,instead of using a timer periodically, but when this thread is strated in a while(true) loop,it doesn't allow the other thread to execute, how can i use the thread.sleep() to do fill th listview periodically

    L H M P 4 Replies Last reply
    0
    • P prasadbuddhika

      in my app i've two threads , one for update the listview and one for main form,the problem is i used thread.sleep() method to update the listview,instead of using a timer periodically, but when this thread is strated in a while(true) loop,it doesn't allow the other thread to execute, how can i use the thread.sleep() to do fill th listview periodically

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

      The actual filling of a ListView should be done from the mainthread if I'm not mistaken. Doing this from another thread has no advantages, since the other thread needs to synchronize with the mainthread anyhow. You can use the second thread to fetch the items that go in the ListView, and you can use it to modify the resultset before inserting them into the ListView.

      I are troll :)

      1 Reply Last reply
      0
      • P prasadbuddhika

        in my app i've two threads , one for update the listview and one for main form,the problem is i used thread.sleep() method to update the listview,instead of using a timer periodically, but when this thread is strated in a while(true) loop,it doesn't allow the other thread to execute, how can i use the thread.sleep() to do fill th listview periodically

        H Offline
        H Offline
        Henry Minute
        wrote on last edited by
        #3

        Do a search for 'InvokeRequired'. That should give you some clues.

        Henry Minute If you open a can of worms, any viable solution *MUST* involve a larger can.

        1 Reply Last reply
        0
        • P prasadbuddhika

          in my app i've two threads , one for update the listview and one for main form,the problem is i used thread.sleep() method to update the listview,instead of using a timer periodically, but when this thread is strated in a while(true) loop,it doesn't allow the other thread to execute, how can i use the thread.sleep() to do fill th listview periodically

          M Offline
          M Offline
          Moim Hossain
          wrote on last edited by
          #4

          Use a delegate to update the List items... Control.Invoke( delegate )..

          Moim Hossain R&D Project Manager BlueCielo ECM Solutions BV

          1 Reply Last reply
          0
          • P prasadbuddhika

            in my app i've two threads , one for update the listview and one for main form,the problem is i used thread.sleep() method to update the listview,instead of using a timer periodically, but when this thread is strated in a while(true) loop,it doesn't allow the other thread to execute, how can i use the thread.sleep() to do fill th listview periodically

            P Offline
            P Offline
            powerwade
            wrote on last edited by
            #5

            I has a same problem too.

            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