CreateThread and AfxBeginThread
-
In MFC what is the difference between these functions and what is the fine line calling AfxBeginThread vs calling ::CreateThread
-
In MFC what is the difference between these functions and what is the fine line calling AfxBeginThread vs calling ::CreateThread
-
In MFC what is the difference between these functions and what is the fine line calling AfxBeginThread vs calling ::CreateThread
The documentation ([^] and [^]) doesn't help, does it? Roughly speaking, you can spot the main difference in the
AfxBeginThread
overloaded form supporting user interface threads, i.e.:CWinThread* AfxBeginThread(
CRuntimeClass* pThreadClass,
int nPriority = THREAD_PRIORITY_NORMAL,
UINT nStackSize = 0,
DWORD dwCreateFlags = 0,
LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL
);The above provides some boiler plate code helping, user interface threads development. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke -
In MFC what is the difference between these functions and what is the fine line calling AfxBeginThread vs calling ::CreateThread
-
In MFC what is the difference between these functions and what is the fine line calling AfxBeginThread vs calling ::CreateThread
On Windows, all the thread creation methods eventually call ::CreateThread() to create the thread. The difference is, AfxBeginThread() does MFC-specific initialization on the thread. The typical rule of thumb is: Use AfxBeginThread() to create a thread in MFC if the thread will use any MFC objects. Use _beginthreadex() to create a thread if no MFC objects are used but CRT functions are used (including new/delete!). Use ::CreateThread() if just Win32 APIs/objects are used. Also make sure you link to the multithread MFC/CRT libraries!! :) Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: