Re: Terminating User-Interface Thread



delvsb wrote:
Good day to all.

I would like to know how to delete a thread even if the if it is still running.

Thank you very much in advance.

When you create the thread you must create it suspended, set m_bAutoDelete false, then ResumeThread.


In the main thread, signal the thread to end itself with PostThreadMessage. In the UI thread message handler, free things and call PostQuitMessage(0);

In the main thread, WaitForSingleObject on the thread handle. Then delete the thread object.

--
Scott McPhillips [VC++ MVP]

.