UI threading with MFC
I've created a thread that auto-saves some text in a control every 30 seconds. However, it's not very good code and I've never done threading before.
Currently, the code in the threads Run() function looks something like this...
There is a timer elsewhere that flips m_bRunning to TRUE causing the WM_AUTOSAVE message to be sent. The function that handles that sets m_bRunning back to FALSE.
This is a pretty ugly setup and the while-loops for m_bRunning are clearly not ideal as they just sit and spin on the CPU.
How else could I execute this code and then put the thread to sleep for a defined period of time before executing again? I've read in numerous places that Sleep() is not a very good thing to do in UI threads for some reason...
Thanks for your help
Re: UI threading with MFC
I've since changed the code to the following...
So no more timer and the thread utilizes Sleep(). Anyone have any thoughts? :|
|All times are GMT +5.5. The time now is 11:58.|