Terminating A Thread Externally
Posted on 2006-07-24
I have an MFC dialog app that shows live updates on information coming into a database. It does this by invoking a thread from OnInitDialog using AfxBeginThread. This thread then goes round in a continuous loop, reading the database info and then outputting it to the screen. The problem I am having is how to close this thread in a controlled way when my main application stops running. I need the chance to return my dynamic memory to avoid debug assertion fail messages on shutdown, and ensure that when I write my data to the screen it will not cause my app to crash because the main dialog has been wrapped up. AfxEndThread can only be called from inside the thread, there a way of terminating the thread from the main dialog app?