Lets say you have a hard working
thread, and also lets say that a
user has changed his mind and wants
to quit this job early. But there's
one problem. This thread is such a
good worker that it ignores all
message's untill it has done the job.
well I would like to beable to stop
this thread, tell it to go on vacation.
I just can't close it off couse this
thread needs to clean stuff up, like
delete temp files it was using, close
off any memory it Allocated, ect.
Any suggestions on how to send this
thread on vacation?
Insert a GetMessage() call somewhere in your threads main loop. Put it somewhere so that you are sure it will be called atleast once every second. Then send a message from your main thread to your child thread using PostThreadMessage().
You have to sacrifice some of your good-working threads speed im afraid.
I tried the GetMessage() and it
seems to make my thread do nothing.
eather I am using it wrong or it dosent
return untill there is a message. So I
still need some way to check for messages
in my thread...
At Last I have found that if you'
stop thinking so hard, the answer
will come to you. This is such a
simple answer that I am afraid that
it will tarnish my Name. To Send a
message to my thread I can use a DWORD
varible and just poke messages into it.
mov eax,TM_STOPZIPPING
mov ,eax
And in the thread I can have spots
where my thread looks at these messages
and will know when to take action
and what kind. So you see, it is not that hard.
too simple that I overlooked it. I guess if
you create a thread that is not inside the app
itself then you would have to use GetMessage()
ect. So I am happy to say that this is now
put to rest. and thank you for all that
tried to help me with this problem.
Hey there,
GetMessage *waits* until it recieves it's next message, so it will go through your loop once and wait for a message before it continues....
Check out PeekMessage, this API can be used to look to see if their is a message if not you can still continue, otherwise you process the message.
Hope this works out for you!
See ya,
Ben