If I have a member function. . .
MyClass::MyFunction()
{
while(1)
{
//blah blah blah
}
}
. . . and I try to create a thread of this function . . .
CreateThread(Null, 0, (LPTHREAD_START_ROUTINE)MyFunction, NULL, 0, NULL);
. . . I always get an error saying that (LPTREAD_START_ROUTINE)MyFunction is an invalid typecast and that I cannot create a thread of a nonstatic member function.
I cannot make my function static because I use the this pointer several times which requires a nonstatic member function to do so.
Is there any simple way to create a thread of a nonstatic member function?
(I'm working in Visual Studio 2010, C++, MFC)