I am running a thread that does something, then sleeps for a while. If the program closes it continues to sleep to completion. How do I get it to abort immediatly, even if in the middle of sleeping?
I am running a thread that does something, then sleeps for a while. If the program closes it continues to sleep to completion. How do I get it to abort immediatly, even if in the middle of sleeping?
You may use TerminateThread function, it will terminate your thread immediatly, but it is bad practice. Right decision is to follow Ancient Dragon's recomendation and use some of synchronization objects instead -- for example event. Thread may sleep, waiting some event to be signaled, then awake and abort himself with proper resource cleanup, etc...
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.