_beginthreadex static member function

前端 未结 5 1192
名媛妹妹
名媛妹妹 2021-01-24 02:28

How do I create a thread routine of a static member function

class Blah
{
    static void WINAPI Start();
};

// .. 
// ...
// ....

hThread = (HANDLE)_beginthre         


        
5条回答
  •  无人共我
    2021-01-24 03:06

    Following is the compiling version:

    class CBlah
    {
    public:
        static unsigned int WINAPI Start(void*)
        {
        return 0;
        }
    };
    
    int main()
    {
        HANDLE hThread = (HANDLE)_beginthreadex(NULL, 0, &CBlah::Start, NULL, NULL, NULL);
    
        return 0;
    }
    

    Following are the changes required:

    (1). Start() function should return unsigned int

    (2). It should take a void* as the parameter.

    EDIT

    Deleted point (3) as per comment

提交回复
热议问题