-
Killing a thread
I have a thread that reads from my serial port and then writes the information to my active child window. The problem I am having is that If I close the child window the thread tries to write to it causing an error. I would like to know how can I kill the thread when I close the child window. I have set up my OnDestroy function to call the ExitInstance of the CWinthread derived class, but that does not stop the thread. What can I do?
-
Re: Killing a thread
The CWinThread function ExitInstance is a virtual function that you can override in your derived class to do any cleanup for that thread. If you read the documentation of ExitInstance(), it says not to call this function from anywhere other than the Run member function.
If the CWinThread is a user interface thread, you can simply send a WM_QUIT message.
-- Matt