Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
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.

CWinThread::CreateThread 

Creates a thread to execute within the address space of the calling process.


BOOL CreateThread(
   DWORD dwCreateFlags = 0,
   UINT nStackSize = 0,
   LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL 
);

Parameters

dwCreateFlags

Specifies an additional flag that controls the creation of the thread. This flag can contain one of two values:

  • CREATE_SUSPENDED   Start the thread with a suspend count of one. Use CREATE_SUSPENDED if you want to initialize any member data of the CWinThread object, such as m_bAutoDelete or any members of your derived class, before the thread starts running. Once your initialization is complete, use the CWinThread::ResumeThread to start the thread running. The thread will not execute until CWinThread::ResumeThread is called.

  • 0   Start the thread immediately after creation.

nStackSize

Specifies the size in bytes of the stack for the new thread. If 0, the stack size defaults to the same size as that of the process's primary thread.

lpSecurityAttrs

Points to a SECURITY_ATTRIBUTES structure that specifies the security attributes for the thread.

Nonzero if the thread is created successfully; otherwise 0.

Use AfxBeginThread to create a thread object and execute it in one step. Use CreateThread if you want to reuse the thread object between successive creation and termination of thread executions.

Community Additions

ADD
Show:
© 2015 Microsoft