DWORD WINAPI RecvThread(LPVOID lpParameter);
DWORD WINAPI Client::RecvThread(LPVOID lpParameter) { //do stuff }
DWORD WINAPI RecvThread(LPVOID lpParameter);
DWORD WINAPI Client::RecvThread(LPVOID lpParameter) { //do stuff }
DWORD WINAPI RecvThread(LPVOID lpParameter){ for(;;){ RecvData(); // This is a member function. I need to be able to access this member function within the thread }}class CWithAThread{ public: void Start(); private: static DWORD WINAPI ThreadFunc_Static(LPVOID lpParameter); DWORD ThreadFunc(); HANDLE mhThread;};void CWithAThread::Start(){ mhThread = CreateThread(NULL, 0, CWithAThread::ThreadFunc_Static, reinterpret_cast<LPVOID>(this), 0, NULL);}DWORD WINAPI CWithAThread::ThreadFunc_Static(LPVOID lpParameter){ if (lpParameter != NULL) { return reinterpret_cast<CWithAThread*>(lpParameter)->ThreadFunc(); } else { return 1; }}DWORD CWithAThread::ThreadFunc(){ //Do stuff //... //At end: CloseHandle(mhThread); return 0;}DWORD WINAPI RecvThread(LPVOID lpParameter, Client obj) { //do stuff }Quote:
Original post by cherryhouse
I don't quite think I'm explaining myself clearly enough.
I'm not trying to create a thread class. I already know how to create a thread class. What I'm trying to do is pass an object to a thread.
CreateThread( blah, blah, SomeFunction);...DWORD SomeFunction(LPVOID arg){ SomeClass * sc = reinterpret_cast<SomeClass *>(arg); // blah}This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more