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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to stop CComboBox from interrupting thread?

How to stop CComboBox from interrupting thread?

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelptutorialannouncement
6 Posts 5 Posters 1 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
    Greg Ellis
    wrote on last edited by
    #1

    Hi, I have noticed a problem in windows programming that I am unable to solve. I have created a new thread which should run as a separate process. In this thread I continually update a counter so that I Can visually see if and when my thread is interrupted. If I put a CComboBox control on my dialog my thread is momentarily interrupted when the CComboBox is clicked and the list drops down. I have tried creating my thread with realtime priority and the combobox still interrupts my thread when dropped down. Obviously the dropping down of the combobox does not interrupt other applications that are running in separate processes so I do not understand why it would interrupt my thread. unsigned threadID; HANDLE hThread = (HANDLE)_beginthreadex( NULL, 0, &UpdateThread, (void*)this, 0, &threadID ); SetPriorityClass(hThread, HIGH_PRIORITY_CLASS); SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); How can I create a thread that will not be interrupted by the dropping down of the combobox? Thanks, Greg

    G S P R 4 Replies Last reply
    0
    • G Greg Ellis

      Hi, I have noticed a problem in windows programming that I am unable to solve. I have created a new thread which should run as a separate process. In this thread I continually update a counter so that I Can visually see if and when my thread is interrupted. If I put a CComboBox control on my dialog my thread is momentarily interrupted when the CComboBox is clicked and the list drops down. I have tried creating my thread with realtime priority and the combobox still interrupts my thread when dropped down. Obviously the dropping down of the combobox does not interrupt other applications that are running in separate processes so I do not understand why it would interrupt my thread. unsigned threadID; HANDLE hThread = (HANDLE)_beginthreadex( NULL, 0, &UpdateThread, (void*)this, 0, &threadID ); SetPriorityClass(hThread, HIGH_PRIORITY_CLASS); SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); How can I create a thread that will not be interrupted by the dropping down of the combobox? Thanks, Greg

      G Offline
      G Offline
      Garth J Lancaster
      wrote on last edited by
      #2

      I would start looking at how the threaded procedure is communicating with the dialog There are a number of good articles around on comms between a dialog and a worker thread - Im almost tempted to point you here http://www.flounder.com/workerthreads.htm[^] 'g'

      G 1 Reply Last reply
      0
      • G Greg Ellis

        Hi, I have noticed a problem in windows programming that I am unable to solve. I have created a new thread which should run as a separate process. In this thread I continually update a counter so that I Can visually see if and when my thread is interrupted. If I put a CComboBox control on my dialog my thread is momentarily interrupted when the CComboBox is clicked and the list drops down. I have tried creating my thread with realtime priority and the combobox still interrupts my thread when dropped down. Obviously the dropping down of the combobox does not interrupt other applications that are running in separate processes so I do not understand why it would interrupt my thread. unsigned threadID; HANDLE hThread = (HANDLE)_beginthreadex( NULL, 0, &UpdateThread, (void*)this, 0, &threadID ); SetPriorityClass(hThread, HIGH_PRIORITY_CLASS); SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); How can I create a thread that will not be interrupted by the dropping down of the combobox? Thanks, Greg

        S Offline
        S Offline
        Stephen Hewitt
        wrote on last edited by
        #3

        Greg Ellis wrote:

        I have created a new thread which should run as a separate process.

        What does this mean? Is it a thread in the same process or a separate process? How does the thread report its progress exactly?

        Steve

        1 Reply Last reply
        0
        • G Greg Ellis

          Hi, I have noticed a problem in windows programming that I am unable to solve. I have created a new thread which should run as a separate process. In this thread I continually update a counter so that I Can visually see if and when my thread is interrupted. If I put a CComboBox control on my dialog my thread is momentarily interrupted when the CComboBox is clicked and the list drops down. I have tried creating my thread with realtime priority and the combobox still interrupts my thread when dropped down. Obviously the dropping down of the combobox does not interrupt other applications that are running in separate processes so I do not understand why it would interrupt my thread. unsigned threadID; HANDLE hThread = (HANDLE)_beginthreadex( NULL, 0, &UpdateThread, (void*)this, 0, &threadID ); SetPriorityClass(hThread, HIGH_PRIORITY_CLASS); SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); How can I create a thread that will not be interrupted by the dropping down of the combobox? Thanks, Greg

          P Offline
          P Offline
          Parthiban
          wrote on last edited by
          #4

          R u trying to update the counter in dialog and viewing? if drow down box painter u can see some delay in the counter updation in dialog.

          1 Reply Last reply
          0
          • G Garth J Lancaster

            I would start looking at how the threaded procedure is communicating with the dialog There are a number of good articles around on comms between a dialog and a worker thread - Im almost tempted to point you here http://www.flounder.com/workerthreads.htm[^] 'g'

            G Offline
            G Offline
            Greg Ellis
            wrote on last edited by
            #5

            I using PostMessage to send a user defined message on the main GUI thread which then calls SetWindowText on the static control that I am using for a counter. From what I have read this is the only safe way to update the GUI From a separate thread. I am still lost on why the dropping down of the combo box would interrupt the drawing of my counter control.

            1 Reply Last reply
            0
            • G Greg Ellis

              Hi, I have noticed a problem in windows programming that I am unable to solve. I have created a new thread which should run as a separate process. In this thread I continually update a counter so that I Can visually see if and when my thread is interrupted. If I put a CComboBox control on my dialog my thread is momentarily interrupted when the CComboBox is clicked and the list drops down. I have tried creating my thread with realtime priority and the combobox still interrupts my thread when dropped down. Obviously the dropping down of the combobox does not interrupt other applications that are running in separate processes so I do not understand why it would interrupt my thread. unsigned threadID; HANDLE hThread = (HANDLE)_beginthreadex( NULL, 0, &UpdateThread, (void*)this, 0, &threadID ); SetPriorityClass(hThread, HIGH_PRIORITY_CLASS); SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); How can I create a thread that will not be interrupted by the dropping down of the combobox? Thanks, Greg

              R Offline
              R Offline
              Roger Allen
              wrote on last edited by
              #6

              You say you have a worker thread posting messages to the UI thread. Your worker thread is not being interrupted any differently than it was when the combobox is not being used. Windows runs multiple threads by time slicing. Higher priority threads get more slices more often. It appears to you that the thread is interupted by the click but it is not. As your using post message, the UI thread updates the control content. This is the same thread that handles the users click on the combobox. While the UI thread is handling the click combo drop event, any messages posted by the worker thread are being added to the message queue for the UI thread to process once it returns from its current work. The issue you have is that the drop event of the combo is animated and due to this appears to pause the UI while this happens. Apart from re-writing how a combo box works (or some how disabling the animation) I do not beleive there is anything you can do about this. As a test to show its not affectig the worker thread. Time how long it takes for your on screen counter to increment to a set count. Then check that its takes the equivalent time (within a dop of the combobox time threadshold) it should still reach the same count.

              If you vote me down, my score will only get lower

              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