Diff between AfxBeginThread and CreateThread - Programmer

This is a discussion on Diff between AfxBeginThread and CreateThread - Programmer ; Hi, What are the adv./ disadv. of using AfxBeginThread over the Win API CreateThread ?? I hv. a piece of code where both are used and can't seem to figure out why.. Thanks and Regards, M Shetty...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Diff between AfxBeginThread and CreateThread

  1. Diff between AfxBeginThread and CreateThread

    Hi,

    What are the adv./ disadv. of using AfxBeginThread over the Win API CreateThread ??

    I hv. a piece of code where both are used and can't seem to figure out why..

    Thanks and Regards,
    M Shetty

  2. Re: Diff between AfxBeginThread and CreateThread

    mshetty wrote:
    > Hi,
    >
    > What are the adv./ disadv. of using AfxBeginThread over the Win API CreateThread ??
    >
    > I hv. a piece of code where both are used and can't seem to figure out why..
    >
    > Thanks and Regards,
    > M Shetty


    MFC requires AfxBeginThread. It lets the library support your code in
    threads. It also calls _beginthreadex, which is required by the C
    runtime library to support your code in threads. That, in turn, calls
    the CreateThread API. So it you don't use AfxBeginThread you have risks
    that various library features will not work properly. I can't think of
    any reason that calling CreateThread directly would have an advantage,
    and it would only be safe in a thread that does not use either of the
    libraries.

    --
    Scott McPhillips [VC++ MVP]


+ Reply to Thread