This function creates a new thread. The first form of AfxBeginThread creates a worker thread. The second form creates a user-interface thread.
AfxBeginThread creates a new CWinThread object, calls its CreateThread function to start executing the thread, and returns a pointer to the thread. Checks are made throughout the procedure to make sure all objects are deallocated properly should any part of the creation fail. To end the thread, call AfxEndThread from within the thread, or return from the controlling function of the worker thread.
pfnThreadProc Points to the controlling function for the worker thread. Cannot be NULL. This function must be declared as follows: UINT MyControllingFunction( LPVOID pParam );
pParam Parameter to be passed to the controlling function as shown in the parameter to the function declaration in pfnThreadProc.