Original Post
Hi ppl,
Fiddling with multithreading provided me with a problem.
I defined the following class:
Instantiating CTest somewhere in the main thread
CTest Test;
Test.StartThread();
Up to here everything is fine but after the typecast in the threadfunction I constantly get an exception
if I try to call the TestFunc member of the CTest object.
Why is that ? Do I violate some special rule concerning multithreading ?
Maybe some security rights ? From my understanding of threads there shouldn''t be a problem.
Just to make sure: pThread is the correct address of the object I instantiated.
Maybe somebody could tell me about this.
Thanks for any comments.
Lorenz
class CTest
{
public:
CTest(); virtual CTest();
static DWORD __stdcall ThreadRoutine(LPVOID lparam)
{
CTest* pThread = (CTest*)lparam;
pThread->TestFunc();
}
void StartThread()
{
CreateThread(NULL,NULL,ThreadRoutine,this,NULL,NULL);
};
void TestFunc()
{
int x = 0;
}
};