Skip to main content
GameDev.net gamedev.net
🔒 Locked

Multithreading :: MFC

Started by kuphryn Oct 2, 2002 at 5:37 PM 1 replies 350+ views
Original Post
kuphryn
kuphryn
Hi. In an MFC project, is better to implement multithreadingusing AfxBeginThread() or a normal create-thread function such as _beginthread() and CreateThread()? I remember Jeff Prosise recommending AfxBeginThread() for MFC. I would like to get more inputs. Thanks, Kuphryn
Solo
Solo
From his book:

"AfxBeginThread isn''t merely a wrapper around the Win32 ::CreateThread function; in addition to launching a thread, it initalizes internal state information used by the framework, performs sanity checks at various points during the thread creation process, and takes steps to ensure that functions in the C run-time library are accessed in a thread-safe manner." - Jeff Prosise "Programming Windows with MFC" 2nd edition

Pretty important stuff. _beginthread(), or better yet _beginthreadex(), should work if the thread isn''t going to run any MFC code. Just remember that they will skip the "initalizes internal state information" part.

You''d do well to stay away from CreateThread(). It doesn''t prepare the C run-time library.
// Ryan
kuphryn
kuphryn
Okay. Thanks.

Yeah, I know a little about CreateThread and its problems with C run-time. Jeffrey Richter dedicated a section in his Windows programming book about that issue.

Kuphryn

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.