I am working under an MFC environment. I would like to know, What is the performance difference, if any, resulting from the use of _beginthreadex and MFC's AfxBeginThread for an IOCP Winsock model client and server? I understand that for an MFC project, we should use MFC's AfxBeginThread to generate the threads. Nonetheless, does an IOCP client or server require or performs better via _beginthreadex?

The reason I am wondering about this is that I saw some really good examples IOCP servers where the developers used _beginthreadex with MFC instead of AfxBeginThread(). Here is one example.



A second question related to IOCP, _beginthreadex, and MFC's AfxBeginThread is the callback function.

Under MFC's AfxBeginThread, you basically send/post messages from the worker thread the IOCP GetQueuedCompletionStatus() function returns. One the other hand, with _beginthreadex, you have the option of passing in a pointer to the class object itself (this). Thus, you can call a function to process incoming data directly without relying on send/post message.

I would like to know, Is the analysis above true. In other words, does the use of send/post message via IOCP worker threads negatively affect performance?