How to stop a very slow worker thread from the GUI?
First off, thanks for everyone's help in the message passing thread - I made my own message that sends data back to the GUI through PostMessage (no longer requiring bits of the GUI to go to the thread).
New issue: I have a worker thread that loops, but each loop takes 20-30 seconds (or more, depending on complexity) on my 2.8 GHz machine. because of that, the method of checking for a bool "running" or WaitForSingleObject( ) inside the loop before calling AfxEndThread takes entirely too long (being that it may be 20-30 seconds or more before it gets back to that line in the loop).
Terminating the thread seems like an option, but a sloppy one (maybe there's a good way to do it?). Is there some way of stopping the thread cleanly while it's processing? I'd like the user to be able to click a "STOP" button and have everything stop, but be ready to go again.
If it makes any difference, my thread func makes lots of calls to lots of other functions that take lots of time.
Last edited by ecspansion; September 20th, 2004 at 09:33 PM.