I am a newbie in MFC C++ and I just want to ask if anyone knows where can I find a sample code application or could any one share a code of an application of Multithreading in MFC C++ 2005..
thanks in advance..
Printable View
I am a newbie in MFC C++ and I just want to ask if anyone knows where can I find a sample code application or could any one share a code of an application of Multithreading in MFC C++ 2005..
thanks in advance..
Using Worker threads
Using User-Interface Threads
and the serial communications example which uses worker and UI threads: Serial Port I/O
..thank you very much VictorN..
i'll try that right away..
..thank you again.. :)
BTW, just a side note: using MFC does not oblige you to use MFC thread classes and functions exceptionally. It happens all the time in my practice that doing threads in plain Win API looks more natural to me. But this is very personal matter (of habits, preferences, skills, project requirements, coding standards, etc.), and you may find MFC stuff more appropriate/convenient for yourself.
..thank you Igor,
its just that my boss wanted us to learn and code applications with multithreading and synchronization using MFC applications. I'll try using Win app next time :). Thank you again..
Hi Igor,
I've noticed this on flounder.com:
_beginthread(), _beginthreadex(), or CreateThread() in an MFC program
Is that right, and if so do you need some special approach when using the Win API for threads under MFC?
Well there is a lot of discussion about it in the Web...
For example:
http://www.codeguru.com/forum/showthread.php?t=371305
http://www.codeguru.com/forum/showthread.php?t=433100
http://www.microsoft.com/msj/0799/win32/win320799.aspx
Victor, thank you for the collection of the links. In fact talking about WinAPI threads I meant _beginthreadex and CreateThread in contrast to using AfxBeginThread. But regarding specific problem of a choice between _beginthreadex and CreateThread I'd say _beginthreadex is always appears more preferable, of course unless you're absolutely sure you know what you do with CreateThread. :)
Igor, I agree!
Although I prefer using MFC CWinThread with AfxBeginThread for both worker and UI thread types. ;)
In case you use CRT somewhere in thread, directly or indirectly, _beginthreadex is the choice. In case you're not sure if you do, _beginthreadex again is the choice. :) And only if you're absolutely sure you don't (i.e. you use some third party runtime or bare WinAPI), CreateThread is an option.Quote:
Is that right, and if so do you need some special approach when using the Win API for threads under MFC?