ppuniversal
February 20th, 2007, 08:17 AM
Hello,
I am making a thread program, in which i call :
hThread = CreateThread( NULL,
0,
(LPTHREAD_START_ROUTINE)(this->runThread),
this,
0,
&ThreadId);
in the constructor of my class.
Here hThread is the handle to the thread created.
And runThread is my thread function.
The 4th parameter passed is the pointer to my current object, i.e. "this".
The prototype of my runThread function is:
static DWORD WINAPI runThread(LPVOID param);
Now the problem is:
In the runThread function when I convert the "param" to my class type i.e.
MyClass ob = (MyClass)param;
it gives the following error on compilation:
error C2440: 'type cast' : cannot convert from 'LPVOID' to 'MyClass'
Please tell either how to overcome this problem or any other way of passing my object to the runThread function.
Pawan
I am making a thread program, in which i call :
hThread = CreateThread( NULL,
0,
(LPTHREAD_START_ROUTINE)(this->runThread),
this,
0,
&ThreadId);
in the constructor of my class.
Here hThread is the handle to the thread created.
And runThread is my thread function.
The 4th parameter passed is the pointer to my current object, i.e. "this".
The prototype of my runThread function is:
static DWORD WINAPI runThread(LPVOID param);
Now the problem is:
In the runThread function when I convert the "param" to my class type i.e.
MyClass ob = (MyClass)param;
it gives the following error on compilation:
error C2440: 'type cast' : cannot convert from 'LPVOID' to 'MyClass'
Please tell either how to overcome this problem or any other way of passing my object to the runThread function.
Pawan