A thread function should be static. Therefore we cannot access the non-static members from the thread function.
We can solve this issue by passing address of class instance to the thread function. In thread function, we will convert it to an instance of class object and can call member functions of the class.
class MyClass
{
struct THREAD_INFO
{
MyClass* pInstance;
int nScenarioToStart; .... }
UINT ThreadFunc( LPVOID pInstance )
{
THREAD_INFO* pThreadInfo = (THREAD_INFO*)pInstance;
pThreadInfo->pInstance->ThreadImpl(pThreadInfo); return 1;
)
void ThreadImpl(THREAD_INFO* pThreadParam)
{
}
}