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. Updating form controls from a spawned thread

Updating form controls from a spawned thread

Scheduled Pinned Locked Moved C#
questionannouncement
7 Posts 4 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.
  • T Offline
    T Offline
    tiwal
    wrote on last edited by
    #1

    I am trying to update a textbox in my main form, from a thread that I started in the click handler of a button of the form itself .... it keeps sending the exception that I can't do that from a thread other than that which created the control ... how can it be ? how can I get to update that damn textbox using a different thread ? there' s no other way my program can work .....

    L L 2 Replies Last reply
    0
    • T tiwal

      I am trying to update a textbox in my main form, from a thread that I started in the click handler of a button of the form itself .... it keeps sending the exception that I can't do that from a thread other than that which created the control ... how can it be ? how can I get to update that damn textbox using a different thread ? there' s no other way my program can work .....

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

      From your thread;

      List MyData;
      UpdateGUI(MyData);

      In the form;

      void UpdateGUI(List someData)
      {
      if (InvokeRequired)
      {
      Invoke(new Action>(UpdateGUI), new object[] { someData });
      return;
      }
      // update the gui here
      }

      MSDN[^] holds some nice examples.

      Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

      1 Reply Last reply
      0
      • T tiwal

        I am trying to update a textbox in my main form, from a thread that I started in the click handler of a button of the form itself .... it keeps sending the exception that I can't do that from a thread other than that which created the control ... how can it be ? how can I get to update that damn textbox using a different thread ? there' s no other way my program can work .....

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        This article[^] tells you more about the subject. :)

        Luc Pattyn [My Articles] Nil Volentibus Arduum

        T P 2 Replies Last reply
        0
        • L Luc Pattyn

          This article[^] tells you more about the subject. :)

          Luc Pattyn [My Articles] Nil Volentibus Arduum

          T Offline
          T Offline
          tiwal
          wrote on last edited by
          #4

          Great info ... now it seems I can make it work .... Thanks a lot for the input ! Leo :thumbsup:

          1 Reply Last reply
          0
          • L Luc Pattyn

            This article[^] tells you more about the subject. :)

            Luc Pattyn [My Articles] Nil Volentibus Arduum

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #5

            Are you all right my old friend? We haven't seen you in such a long time.

            *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

            "Mind bleach! Send me mind bleach!" - Nagy Vilmos

            CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

            L 1 Reply Last reply
            0
            • P Pete OHanlon

              Are you all right my old friend? We haven't seen you in such a long time.

              *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

              "Mind bleach! Send me mind bleach!" - Nagy Vilmos

              CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              No worries, I'm fine, thanks. After long consideration I have decided not to spend time around here anymore. I don't like what CP has turned itself into; when publishing articles became nearly impossible, the bugs & sucks forum became the most active one, and CP staff didn't seem to care about it, I decided it was time to move on. When they seem to focus on membership counts, parallel sites, cosmetics, i.e. everything but quality and contributor's comfort, well that is their choice. The automatic downvote on every new message nailed it for me; it was yet another example of the don't-think-don't-test policy that had crept in. Maybe in the mean time things have changed for the better (I doubt it), I have no idea what the functionality or quality of the site currently is, I do know the new layout is making sure I won't return. I have enjoyed the site and the community for many years; I learned a lot in the 5+ years I have been active here, and I am grateful for the guidance people like yourself have offered. I'll miss a number of nice guys (some of them long gone), and I will cherish the good memories, however this chapter has been closed. So goodbye it is. :beer: PS: While I much appreciate your enquiry, I unchecked e-mail notifications, as I don't want to enter a discussion on this subject. I had decided to leave quietly, and don't want to stir things up now.

              Luc Pattyn [My Articles] Nil Volentibus Arduum

              P 1 Reply Last reply
              0
              • L Luc Pattyn

                No worries, I'm fine, thanks. After long consideration I have decided not to spend time around here anymore. I don't like what CP has turned itself into; when publishing articles became nearly impossible, the bugs & sucks forum became the most active one, and CP staff didn't seem to care about it, I decided it was time to move on. When they seem to focus on membership counts, parallel sites, cosmetics, i.e. everything but quality and contributor's comfort, well that is their choice. The automatic downvote on every new message nailed it for me; it was yet another example of the don't-think-don't-test policy that had crept in. Maybe in the mean time things have changed for the better (I doubt it), I have no idea what the functionality or quality of the site currently is, I do know the new layout is making sure I won't return. I have enjoyed the site and the community for many years; I learned a lot in the 5+ years I have been active here, and I am grateful for the guidance people like yourself have offered. I'll miss a number of nice guys (some of them long gone), and I will cherish the good memories, however this chapter has been closed. So goodbye it is. :beer: PS: While I much appreciate your enquiry, I unchecked e-mail notifications, as I don't want to enter a discussion on this subject. I had decided to leave quietly, and don't want to stir things up now.

                Luc Pattyn [My Articles] Nil Volentibus Arduum

                P Offline
                P Offline
                Pete OHanlon
                wrote on last edited by
                #7

                Just in case you read this message, I wish you well for the future, and you should leave here knowing that you were appreciated, and that you did make a difference - and no one can ask for more than that. All the best for the future my friend, and if I'm ever back over in Belgium, the drinks are on me.

                *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                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