vorpalarrow
March 20th, 2006, 06:22 PM
I apologize if someone has already asked a similar question.
I have a dialog based application which starts an AfxThread inside my ImageProcessingThread class which continually loops and processes on either a set of images from file or files grabbed from a digital camera. The thread also notifies the dialog which has been set as a listener to use the information that has been retrieved from the processed image.
When the dialog stop button is pressed it sets a variable m_isRunning to false so the main process loop of the thread exits. Before the function that sets the boolean returns it calls WaitForMultipleObjectsEx() on the event handle for m_threadStopEvent which will get set when the main process loop of the thread exits and cleans up it's memmory. Afterwards, AfxEndThread(0) will be called and the thread will have completely exited.
This works fine until I added a CListCtrl to the dialog. Information about the processed image is added to the CListCtrl in the UseInformation() call that gets called after every image is processed in the thread.
With the added CListCtrl being updated inside the thread, when the thread is told to exit it consistently times out on the WaitForMultipleObjectsEx() call.
When I don't update the ClistCtrl, WaitForMultipleObjectsEx() does not timeout. I am really puzzled by this. Processing time does not seem to be an issue because one whole process loop takes less than a second and the timeout is set to 5 seconds.
Why is the CListCtrl interfering with my thread exiting?
When CListCtrl is being updated by the ImageProcessingThread :
If I step through the code, breakpoints in the thread never get reached after WaitForMultipleObjectsEx() is called by the dialog.
When ClistCtrl updating is removed:
The same breakpoints are reached after WaitForMultipleObjectsEx() is called.
I have a dialog based application which starts an AfxThread inside my ImageProcessingThread class which continually loops and processes on either a set of images from file or files grabbed from a digital camera. The thread also notifies the dialog which has been set as a listener to use the information that has been retrieved from the processed image.
When the dialog stop button is pressed it sets a variable m_isRunning to false so the main process loop of the thread exits. Before the function that sets the boolean returns it calls WaitForMultipleObjectsEx() on the event handle for m_threadStopEvent which will get set when the main process loop of the thread exits and cleans up it's memmory. Afterwards, AfxEndThread(0) will be called and the thread will have completely exited.
This works fine until I added a CListCtrl to the dialog. Information about the processed image is added to the CListCtrl in the UseInformation() call that gets called after every image is processed in the thread.
With the added CListCtrl being updated inside the thread, when the thread is told to exit it consistently times out on the WaitForMultipleObjectsEx() call.
When I don't update the ClistCtrl, WaitForMultipleObjectsEx() does not timeout. I am really puzzled by this. Processing time does not seem to be an issue because one whole process loop takes less than a second and the timeout is set to 5 seconds.
Why is the CListCtrl interfering with my thread exiting?
When CListCtrl is being updated by the ImageProcessingThread :
If I step through the code, breakpoints in the thread never get reached after WaitForMultipleObjectsEx() is called by the dialog.
When ClistCtrl updating is removed:
The same breakpoints are reached after WaitForMultipleObjectsEx() is called.