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 / C++ / MFC
  4. progress window threads

progress window threads

Scheduled Pinned Locked Moved C / C++ / MFC
6 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.
  • V Offline
    V Offline
    VC Maniac
    wrote on last edited by
    #1

    I have application in which I need to show a progress window frm a worker thread. create another thread for the progress window and launch the dialog. Now I need to change the status text on the progress dilog. I try sendmessage, but that doesn't work.

    L S S D 4 Replies Last reply
    0
    • V VC Maniac

      I have application in which I need to show a progress window frm a worker thread. create another thread for the progress window and launch the dialog. Now I need to change the status text on the progress dilog. I try sendmessage, but that doesn't work.

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

      Hi Ron, Can you show us how you are posting the message to the dialog created from the worker thread? Best Wishes, -David Delaune

      1 Reply Last reply
      0
      • V VC Maniac

        I have application in which I need to show a progress window frm a worker thread. create another thread for the progress window and launch the dialog. Now I need to change the status text on the progress dilog. I try sendmessage, but that doesn't work.

        S Offline
        S Offline
        Sarath C
        wrote on last edited by
        #3

        ThisIsMeRon wrote:

        I have application in which I need to show a progress window frm a worker thread

        Worker thread probably will be busy with some other processing so it's always better to run the progress GUI in different UI thread(Which is able to process the UI messages). Sharing the MFC Window handle (CWnd or it's derivatives) objects across thread is not safe. So pass the HWND of progress bar UI (Dialog, control or whatsoever) and you can simply Post/Send message using this handle. If you've properly mapped the message in the destination window, it will surely receive it. Please try to post snippets from your code.

        -Sarath. "Great hopes make everything great possible" - Benjamin Franklin

        My blog - Sharing My Thoughts

        1 Reply Last reply
        0
        • V VC Maniac

          I have application in which I need to show a progress window frm a worker thread. create another thread for the progress window and launch the dialog. Now I need to change the status text on the progress dilog. I try sendmessage, but that doesn't work.

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #4

          You should create the progress window in the main UI thread and send/post messages to it from the worker thread, really. Just don't send too many messages. Probably posting is better, otherwise the worker thread is going to wait for the progress message to be processed, which rather defeats the object of having a separate worker thread!

          V 1 Reply Last reply
          0
          • S Stuart Dootson

            You should create the progress window in the main UI thread and send/post messages to it from the worker thread, really. Just don't send too many messages. Probably posting is better, otherwise the worker thread is going to wait for the progress message to be processed, which rather defeats the object of having a separate worker thread!

            V Offline
            V Offline
            VC Maniac
            wrote on last edited by
            #5

            I got it working.. I created a new thread. In the thread I call Domodal() on progress dialog's global object. Then everytime I need to change some status I just call the Set... member functions using the global object.

            1 Reply Last reply
            0
            • V VC Maniac

              I have application in which I need to show a progress window frm a worker thread. create another thread for the progress window and launch the dialog. Now I need to change the status text on the progress dilog. I try sendmessage, but that doesn't work.

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              ThisIsMeRon wrote:

              I have application in which I need to show a progress window frm a worker thread.

              Not a good idea. The UI component should be owned by the primary thread. The secondary (i.e., worker) thread should post messages to the primary thread indicating the progress. It's all explained in more detail here.

              "Love people and use things, not love things and use people." - Unknown

              "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

              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