Threads and Memory Access Violations

Hello,
I have an application that creates a thread.
There are occasions when my application is
terminated because of memory access violation.
The compiler just displays the state of the
CPU when this happens and I have no idea where
in my code the access violation takes place.

The thread is created as follows:

class MyClass{
private:
DWORD dw;
HANDLE hMyThread;
... ...
public:
void Start();
void MyThreadRoutine();
... ...
};

void MyClass::Start(){
hMyThread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE)NonClassRoutine,
&dw, NULL);
}

MyClass::MyThreadRoutine(){
// Do something
}

//////////////////////////////////
MyClass myClass;

DWORD WINAPI NonClassRoutine(LPVOID lpVoid){
myClass.MyThreadRoutine();
return(1);
}

Is there anything wrong with my setup?

Your help is greatly appreciated.




Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories