Jump to content

[SOLVED] Truble with Async class


photo

Recommended Posts

Posted

Hi!

 

In your reference manual written that "run" function in Async class can runs the given function of a class.

 

But I have an error in this case:

class Bar
{
	Bar(){}

	~Bar(){}

	int foo()
	{
		log.message("foo was executed\n");
		return 1;
	}
};

void start_button_click()
{
	Async async = new Async();
	Bar br = new Bar();
	async.run(br, "foo");
}

Error: "Async::run(): unknown type of argument (Bar)"

 

Am I doing something wrong?

Posted

 

int run (variable name,variable v0)

Runs the given function with one argument or a member of a class in asynchronous way. Arguments
  • variable name - Function to be run: string - function name, int - function ID, object - class name.
  • variable v0 - If name is an object: class member name or ID; otherwise - function argument.

 

And I tried to swap arguments, but it doesn't work too.

Posted

You're right, looks like it works for external classes but not for user classes.

 

As workaround, you can use a global function like:

/*
 */
void callFoo(Bar br) { br.foo(); }

/*
 */
void start_button_click()
{
    Async async = new Async();
    Bar br = new Bar();
    async.run("callFoo", br, "foo");
}

Posted

Are you using namespaces ? If so try specifying class name including namespace prefix. Maybe this helps

Posted

ivan.cuevas, I already use this way =)

Posted

ulf.schroeter, I don't use a namespace.

Posted

silent, ok. But if it possible, please, add support of user classes. It will be great =)

×
×
  • Create New...