CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Apr 2011
    Posts
    5

    Arrow MFC C++ 2005 Multithreading Help

    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..

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: MFC C++ 2005 Multithreading Help

    Using Worker threads
    Using User-Interface Threads
    and the serial communications example which uses worker and UI threads: Serial Port I/O
    Victor Nijegorodov

  3. #3
    Join Date
    Apr 2011
    Posts
    5

    Smile Re: MFC C++ 2005 Multithreading Help

    ..thank you very much VictorN..
    i'll try that right away..
    ..thank you again..

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: MFC C++ 2005 Multithreading Help

    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.
    Best regards,
    Igor

  5. #5
    Join Date
    Apr 2011
    Posts
    5

    Re: MFC C++ 2005 Multithreading Help

    ..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..

  6. #6
    Join Date
    Aug 2008
    Location
    Scotland
    Posts
    379

    Re: MFC C++ 2005 Multithreading Help

    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?

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: MFC C++ 2005 Multithreading Help

    Victor Nijegorodov

  8. #8
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: MFC C++ 2005 Multithreading Help

    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.
    Best regards,
    Igor

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: MFC C++ 2005 Multithreading Help

    Igor, I agree!
    Although I prefer using MFC CWinThread with AfxBeginThread for both worker and UI thread types.
    Victor Nijegorodov

  10. #10
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: MFC C++ 2005 Multithreading Help

    Is that right, and if so do you need some special approach when using the Win API for threads under MFC?
    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.
    Best regards,
    Igor

  11. #11
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: MFC C++ 2005 Multithreading Help

    Quote Originally Posted by VictorN View Post
    Although I prefer using MFC CWinThread with AfxBeginThread for both worker and UI thread types.
    Yep, exactly what I meant. Habits, preferences and other stuff...
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured