Creating Threads with MFC

MFC provides the CWinThread class to provide support for creating threads, and is similar in many respects to CWinApp in the methods it supports. This class can be used to manage worker and user interface threads because, like CWinApp, it implements a message loop.

Although MFC provides a class to manage threads, you still need to create a global thread function that has the following prototype:

UINT MFCThreadProc(LPVOID lpParameter);

The MFC function AfxBeginThread can be called to create a worker thread using the thread function:

CWinThread* pThread =
  AfxBeginThread(MFCThreadProc, NULL);

The function AfxBeginThread is passed a pointer to the thread function and a pointer to data to pass to the LPVOID parameter ...

Get Windows® CE 3.0 Application Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.