Jump to content

[SOLVED] Truble with Async class


photo

Recommended Posts

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?

Link to comment

 

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.

Link to comment

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");
}

Link to comment
×
×
  • Create New...