Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
CWinThread Class
Collapse the table of content
Expand the table of content

CWinThread Class

Updated: July 2009

Represents a thread of execution in an MFC application.

class CWinThread : public CCmdTarget

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.

You cannot access MFC libraries in a thread that you created by using _beginthread, _beginthreadex or CreateThread.

For more information about multithreading in MFC, see the following topics:

Header: afxwin.h

Date

History

Reason

July 2009

Clarified the two methods of thread creation in MFC. Added cross-references.

Customer feedback.

Community Additions

ADD
Show:
© 2015 Microsoft