Threads

Started by
0 comments, last by El_Bosso 22 years, 9 months ago
Hi, Is there any way to create a Thread in a Class, which start-function is also in the class, and not a normal function?
Advertisement
Declare the function you want to call as a static member. Like this:

  static void CClass::EntryProc(void* pPointer)  


In the implementation you could do this:

  void CClass::EntryProc(void* pPointer){  CClass* pCaller = (CClass*)pPointer;  assert(pPointer) // Must have a pointer to the caller    pPointer->DoSomething();}  


Call it like this:
  void CClass::NewThread(){  _beginthread(EntryProc,0,(void*)this);}  


Edited by - Imois on July 20, 2001 3:26:16 PM

This topic is closed to new replies.

Advertisement