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. WorkerThread + ProgressDlg

WorkerThread + ProgressDlg

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
4 Posts 2 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
    Peter Molnar
    wrote on last edited by
    #1

    Hi, I have a worker thread for some file processing, the status of which I wanna display on a Progress dialog. I took advantage of the built in progress dialog in Add To Project/Components and Controls. I create and manipulate the Progress dlg in the worker thread using the pointer to CProgressDlg passed from AfxBeginThread's 2 parameter to the worker thread. Problem: the Progress dialog has very slow responsiveness to buttonclicks as if there were no threads involved at all. What's wrong? Thanks Bunburry

    T 1 Reply Last reply
    0
    • P Peter Molnar

      Hi, I have a worker thread for some file processing, the status of which I wanna display on a Progress dialog. I took advantage of the built in progress dialog in Add To Project/Components and Controls. I create and manipulate the Progress dlg in the worker thread using the pointer to CProgressDlg passed from AfxBeginThread's 2 parameter to the worker thread. Problem: the Progress dialog has very slow responsiveness to buttonclicks as if there were no threads involved at all. What's wrong? Thanks Bunburry

      T Offline
      T Offline
      Todd Smith
      wrote on last edited by
      #2

      Each thread should have it's own message loop. Maybe your implementation does not? Todd Smith CPUA 0x007 ... shaken not stirred

      P 1 Reply Last reply
      0
      • T Todd Smith

        Each thread should have it's own message loop. Maybe your implementation does not? Todd Smith CPUA 0x007 ... shaken not stirred

        P Offline
        P Offline
        Peter Molnar
        wrote on last edited by
        #3

        the built-in progress dialog has its own message pump which is automatically called by every StepIt or SetPos.

        ASSERT(m\_hWnd!=NULL);
        
        MSG msg;
        // Handle dialog messages
        while(PeekMessage(&msg, NULL, 0, 0, PM\_REMOVE))
        {
          if(!IsDialogMessage(&msg))
          {
            TranslateMessage(&msg);
            DispatchMessage(&msg);  
          }
        }
        

        This is meant... Bunburry

        P 1 Reply Last reply
        0
        • P Peter Molnar

          the built-in progress dialog has its own message pump which is automatically called by every StepIt or SetPos.

          ASSERT(m\_hWnd!=NULL);
          
          MSG msg;
          // Handle dialog messages
          while(PeekMessage(&msg, NULL, 0, 0, PM\_REMOVE))
          {
            if(!IsDialogMessage(&msg))
            {
              TranslateMessage(&msg);
              DispatchMessage(&msg);  
            }
          }
          

          This is meant... Bunburry

          P Offline
          P Offline
          Peter Molnar
          wrote on last edited by
          #4

          Case solved. I will always remember to call

          if (pProgressDlg->CheckCancelButton)
          pProgressDlg->DestroyWindow();

          in the loop of my worker thread. Thanks anyway for your help. Bunburry

          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