class derived from CWinThread
Posted on 2001-08-23
I have a class that i derived from CWinThread. I have a dialog box app that starts two threads (or more) when it starts. these threads execute some code that then wait a certain amount of time before it repeats the process. I am using the Sleep function to wait the certain amount of time.
What i would like to do is modifiy the code so that it works like this. the thread executes the code and then waits a certain amount of time. While it is waiting it can recieve messages. the message that it should be waiting to recieve would be execute code now. So it would work like this or something like it
thread executes code
thread waits a set amount of time AND can accept messages
while it waits it can accept a message to execute code now
If no such message comes then it waits for the set amount of time then executes the code and then waits again.
While it waits it can accept the execute code command at any time BUT does not reset the timer. So it the timer is set for 5 minutes and the execute code message is recieve 5 seconds before the timer is up the code is executed and when the timer ends in 5 secs the code is executed again and the timer starts all over again
UNLESS the message to quit the thread is recieved. Any time this message is recieved then the thread shuts down and free up an memory it was using.