Hi Tom
Yes, I should have been more specific. This isn't a good replacement for
terminating a thread in an orderly manner. That said, I have found recently
that using a flag to indicate that the thread does not always work. My
example is where I set my flag to false (to terminate the thread) and then
use thread Join to wait for it to terminate. It never does. If I allow the
application to run on, or use a DoEvents (ugh!), then the thread terminates.
I now use the thread Abort method and trap the exception raised in the
thread. It's not pretty, but it works, and permits some sort of graceful
exit.
Charles
[Incidently, I currently have a problem based on the non-terminating issue
above, that involves SyncLock. There are three threads, including the main
UI thread, all trying to send and receive commands down a serial port. All
commands go out through a single function, making it easier to protect.
However, while the two background threads are hammering away at sending and
receiving commands, if I try to send a command from the UI the UI thread
freezes trying to get a lock on my command queue. Once it does that I can't
find out what the other threads are doing in the debugger, as any
breakpoints I set in the body of the threads are never hit. I'm not sure I
have given you enough to go on, but any suggestions about debugging
multi-threaded apps greatly received.]