Jump to content

[SOLVED] run a class function with thread


photo

Recommended Posts

it seems i can run thread in this way thread("function2",A). the function2 is a global function which call A.function1.

but if i use "wait" keyword in the function, it will have an error 

Interpreter::runFunction(): depth of stack is not zero

any idea how to use wait in a class?

Link to comment

Hi,

 

Assumig that you are trying to do something like that in a thread:

class A {
 
 void heavy_func() {
  // process 1
  wait;
  // process 2
  wait;
  // process 3
  wait;
 }
};

A a = new A();
thread("heavy_func",a);
Unfortunately, this code would not work. You can try to modify your code to look more like this:

class A {
 
 void process1();
 void process2();
 void process3();
};

void heavy_func(A a) {
 a.process1();
 wait;
 a.process2();
 wait;
 a.process3();
 wait;
}

A a = new A();
thread("heavy_func",a);
 

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
×
×
  • Create New...