Creating task with member function

I’m having trouble creating a task with a member function. Here is the error:

The task was declared in the header file:

AsyncTask::DoneStatus Task(GenericAsyncTask* task,void* data);

and declared in the constructor:

task=GenericAsyncTask("MyTaskName",&Player::Task,(void*)NULL);

Here is the Task member function:

AsyncTask::DoneStatus Player::Task(GenericAsyncTask* task,void* data){
	std::cout << task->get_elapsed_time() << std::endl;
	return AsyncTask::DS_cont;
}

Thanks for any help :slight_smile:

Hi

Try this:

in header file: (note the declare task, and static)

PT(GenericAsyncTask) task;
static AsyncTask::DoneStatus Task(GenericAsyncTask* task, void* data);

in the constructor: (note new)

task= new GenericAsyncTask("MyTaskName", (GenericAsyncTask::TaskFunc*)Player::Task, (void*)NULL);

I already had task declared, but being forgetful I forgot to include it :blush:
I didn’t realize that task functions had to be static too, thanks!