|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
Updated: July 2009
Represents a thread of execution in an MFC application.
There are two ways to create a thread in MFC. You can call AfxBeginThread, which returns a pointer to the new CWinThread object. When you use AfxBeginThread, the CWinThread object is deleted by default when the thread terminates. To prevent deletion, pass the CREATE_SUSPENDED flag to AfxBeginThread to suspend the thread after it is created, then set CWinThread::m_bAutoDelete to FALSE and call CWinThread::ResumeThread.
You can also create a thread by using the new operator to construct a CWinThread object and calling CWinThread::CreateThread. Use this process if you want to use the CWinThread object to create another thread after the thread terminates.
For more information about multithreading in MFC, see the following topics: