I am implementing a thread which consist will call the pass in function (using function pointer) continueously.
My thread class is the following:
lass MyThread : public Thread
// function pointer
void (*ptr) (void);
HANDLE eventRun; // event for Run
HANDLE eventDie; // event for Die
void * baseClass; // point to the base class
MyThread(int n, const char* nm, void * base);
void myThreadFunction(void (*funcPtr) (void)); // (the problem method A)
void triggerEvent(EVENT e);
When I create the thread object, I will pass in a function pointer like this:
>> myThread = new MyThread(1, "MyListener", this);
>> void (CMyNetwork::*ptr) (void);
>> ptr = &CMyNetwork::listenerMethod;
where listenerMethod is defined like this:
>> void listenerMethod(void);
I realize that the problem error is wrong, since my function pointer is pointing to an member function of the class CMyNetwork::listenerMethod, but I want the thread object independent to the network (cause of the two class linking to each other). Is there solution for my problem.
Or if there is an alternative way to implement that.
Thank you very much for reading this post.
0 · ·