Threads in Classes
-
Hi all, When using the CreateThread within a class, is it possible to provide a method of the class as the lpStartAddress?
m_hBroadcastThread = CreateThread(0,0, (LPTHREAD_START_ROUTINE)BroadcastThread, 0,0,&id);
... where BroadcastThread is the name of a method within the class. It's header is as follows:DWORD CNotificationsHandler::BroadcastThread(LPDWORD param)
I keep getting the following compiler error: error C2440: 'type cast' : cannot convert from '' to 'unsigned long (__stdcall *)(void *)' Your help would be greatly appreciated. Mark -
Hi all, When using the CreateThread within a class, is it possible to provide a method of the class as the lpStartAddress?
m_hBroadcastThread = CreateThread(0,0, (LPTHREAD_START_ROUTINE)BroadcastThread, 0,0,&id);
... where BroadcastThread is the name of a method within the class. It's header is as follows:DWORD CNotificationsHandler::BroadcastThread(LPDWORD param)
I keep getting the following compiler error: error C2440: 'type cast' : cannot convert from '' to 'unsigned long (__stdcall *)(void *)' Your help would be greatly appreciated. MarkIf the thread method is in the class then it should be declared as static. The member functions of the class has the calling convention as thiscall too, which need to be removed by making it static. and while creating the thread pass 'this' pointer to the thread so that the thread function can access the member functions and variables of the class.
MSN Messenger. prakashnadar@msn.com
-
If the thread method is in the class then it should be declared as static. The member functions of the class has the calling convention as thiscall too, which need to be removed by making it static. and while creating the thread pass 'this' pointer to the thread so that the thread function can access the member functions and variables of the class.
MSN Messenger. prakashnadar@msn.com
-
Hi all, When using the CreateThread within a class, is it possible to provide a method of the class as the lpStartAddress?
m_hBroadcastThread = CreateThread(0,0, (LPTHREAD_START_ROUTINE)BroadcastThread, 0,0,&id);
... where BroadcastThread is the name of a method within the class. It's header is as follows:DWORD CNotificationsHandler::BroadcastThread(LPDWORD param)
I keep getting the following compiler error: error C2440: 'type cast' : cannot convert from '' to 'unsigned long (__stdcall *)(void *)' Your help would be greatly appreciated. MarkSee the FAQ 6.1 Why can't I use a member function as a callback?[^] --Mike-- Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- Pinky, are you pondering what I'm pondering? I think so Brain, but if we shaved our heads, we'd look like weasels!
-
Hi all, When using the CreateThread within a class, is it possible to provide a method of the class as the lpStartAddress?
m_hBroadcastThread = CreateThread(0,0, (LPTHREAD_START_ROUTINE)BroadcastThread, 0,0,&id);
... where BroadcastThread is the name of a method within the class. It's header is as follows:DWORD CNotificationsHandler::BroadcastThread(LPDWORD param)
I keep getting the following compiler error: error C2440: 'type cast' : cannot convert from '' to 'unsigned long (__stdcall *)(void *)' Your help would be greatly appreciated. MarkAlso, if you are using the C Runtime Library AT ALL, you might want to be using beginthreadex instead of CreateThread. CreateThread does NOT initialize some thread local data used by each thread in the C run time library.