Re: friends of a class...
ammm,
post the prototybe of class
where u wanna create thread
look for example the prototype of my class like this
class MyClass {
private:
HANDLE hThread;
DWORD dwThreadID;
public:
MyClass() {};
void SetupThread();
void Proc();
void RunThread();
~MyClass() {};
};
the prototype of external function like this
DWORD WINAPI ThreadFunction(MyClass * const lpMyObject);
now where to create my thread ?
void MyClass::SetupThread() {
hThread = CreateThread(NULL, // Pointer to Security Attributes
0, // Stack Size The Same Size As
Primary Thread Of The Process
(LPTHREAD_START_ROUTINE)
ThreadFunction, // Address Of Thread Function
this, // Argument For New Thread
Function (the pointer to the object)
CREATE_SUSPENDED, // Creation
Flags
&dwThreadID); // address of thread
id
}
inside the class method named SetupThread, it will call the external
function named ThreadFunction , and will pass a pointer to the caller
object 'this'
when the thread resumed the function ThreadFunction will executed and
will call Proc() from the pointer passed to it like this
DWORD WINAPI ThreadFunction(MyClass * const lpMyObject) {
lpMyObject->Proc();
return 0;
}
now did i need to pass data to Proc() ? no, why ? coz all data that i
need exected in the object data members
if it is clear now , ok, else post ur code to understand ur problem
Ahmed