-
January 29th, 2004, 10:03 AM
#1
Spawning a class member function into a thread
Is it possible to spawn a class member function into a thread?
I try to do that, but get this error: error C2664: 'CreateThread' : cannot convert parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *)(void *)'
For example, can we have something like this
class C
{
public:
DWORD m_threadId;
HANDLE m_hThread;
DWORD WINAPI ThreadFunction(LPVOID lparam);
void f1(void);
}
void C::f1(void){
m_hThread = CreateThread(NULL, NULL, ThreadFunction, NULL,
NULL, &m_threadId);
}
TIA.
rh
-
January 29th, 2004, 10:07 AM
#2
Take a look at the following FAQ...
-
January 29th, 2004, 11:33 AM
#3
Define the member function as a static public member fuction. Include "__stdcall" so the compiler will accept it.
Kuphryn
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|