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. TreeView.BeginUpdate causing what seems like the thread to lock

TreeView.BeginUpdate causing what seems like the thread to lock

Scheduled Pinned Locked Moved C#
helpquestion
8 Posts 3 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.
  • G Offline
    G Offline
    Gareth H
    wrote on last edited by
    #1

    When updating a TreeView, I call BeginUpdate() before adding any nodes. Every now and again, when this is done the thread seems to halt and does not get past the BeginUpdate() call. The problem is that this happens intermittently, thus sometimes I can spend 30mins trying to reproduce the problem, and it never happens, but other times it happens first attempt. Has anyone seen this happen? or knows of a problem with BeginUpdate?

    Regards, Gareth. (FKA gareth111)

    S F 2 Replies Last reply
    0
    • G Gareth H

      When updating a TreeView, I call BeginUpdate() before adding any nodes. Every now and again, when this is done the thread seems to halt and does not get past the BeginUpdate() call. The problem is that this happens intermittently, thus sometimes I can spend 30mins trying to reproduce the problem, and it never happens, but other times it happens first attempt. Has anyone seen this happen? or knows of a problem with BeginUpdate?

      Regards, Gareth. (FKA gareth111)

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      Gareth H wrote:

      Has anyone seen this happen? or knows of a problem with BeginUpdate?

      Any chance of BeginUpdate being called on a different thread?

      Regards Senthil [MVP - Visual C#] _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

      G 1 Reply Last reply
      0
      • S S Senthil Kumar

        Gareth H wrote:

        Has anyone seen this happen? or knows of a problem with BeginUpdate?

        Any chance of BeginUpdate being called on a different thread?

        Regards Senthil [MVP - Visual C#] _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

        G Offline
        G Offline
        Gareth H
        wrote on last edited by
        #3

        No, since i do a If (InvokeRequired) at the top of the method.

        Regards, Gareth. (FKA gareth111)

        S 1 Reply Last reply
        0
        • G Gareth H

          No, since i do a If (InvokeRequired) at the top of the method.

          Regards, Gareth. (FKA gareth111)

          S Offline
          S Offline
          S Senthil Kumar
          wrote on last edited by
          #4

          Hmm. There's one problem I've seen with InvokeRequired - it returns false if the control's underlying Win32 handle hasn't been created. And that happens if the control hasn't become visible yet.

          Regards Senthil [MVP - Visual C#] _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

          G 1 Reply Last reply
          0
          • S S Senthil Kumar

            Hmm. There's one problem I've seen with InvokeRequired - it returns false if the control's underlying Win32 handle hasn't been created. And that happens if the control hasn't become visible yet.

            Regards Senthil [MVP - Visual C#] _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro

            G Offline
            G Offline
            Gareth H
            wrote on last edited by
            #5

            The control is visible but not enabled.

            Regards, Gareth. (FKA gareth111)

            1 Reply Last reply
            0
            • G Gareth H

              When updating a TreeView, I call BeginUpdate() before adding any nodes. Every now and again, when this is done the thread seems to halt and does not get past the BeginUpdate() call. The problem is that this happens intermittently, thus sometimes I can spend 30mins trying to reproduce the problem, and it never happens, but other times it happens first attempt. Has anyone seen this happen? or knows of a problem with BeginUpdate?

              Regards, Gareth. (FKA gareth111)

              F Offline
              F Offline
              fracalifa
              wrote on last edited by
              #6

              Hi Gareth, I know your post is 3 month ago ... but I have the same problem seen right now. I can fill the tree a hundred time with no problem and then it happens after the third call. I didn't found a way to unlock the control - did you ? Until a better idea is supplied I don't use BeginUpdate() Regards, Frank

              G 1 Reply Last reply
              0
              • F fracalifa

                Hi Gareth, I know your post is 3 month ago ... but I have the same problem seen right now. I can fill the tree a hundred time with no problem and then it happens after the third call. I didn't found a way to unlock the control - did you ? Until a better idea is supplied I don't use BeginUpdate() Regards, Frank

                G Offline
                G Offline
                Gareth H
                wrote on last edited by
                #7

                Frank, The problem with my code was that i was doing an:

                If (InvokeRequired)

                On the main control class, which always returned false when the problem occurred, but the actaul TreeView control was returned true for InvokeRequired. Thus, the solution was to invoke on the TreeView control. If you need some more info, just say.

                Regards, Gareth. (FKA gareth111)

                F 1 Reply Last reply
                0
                • G Gareth H

                  Frank, The problem with my code was that i was doing an:

                  If (InvokeRequired)

                  On the main control class, which always returned false when the problem occurred, but the actaul TreeView control was returned true for InvokeRequired. Thus, the solution was to invoke on the TreeView control. If you need some more info, just say.

                  Regards, Gareth. (FKA gareth111)

                  F Offline
                  F Offline
                  fracalifa
                  wrote on last edited by
                  #8

                  Gareth, thank you for your answer, I see your problem was different, but I have the problem of a treeview lock when using BeginUpdate / EndUpdate. My program worked 4 years without error under .NET 1.1 and I got the problems changing to .NET 2.0 SP1 - why ever. I have nothing running in parallel tasks or threads which could interfere my program. I left BeginUpdate / EndUpdate unused - no problem any more. But that leaves no good feeling. Regards, Frank

                  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