hi
if i make a call to a native function C++ or java it will lock the game until this function end?
or the call is in other thread?
i need to get some info from a server, and it can take some time, what is the proper way to do this?
thanks
David
hi
if i make a call to a native function C++ or java it will lock the game until this function end?
or the call is in other thread?
i need to get some info from a server, and it can take some time, what is the proper way to do this?
thanks
David
Could you use the WWW class?
Or start a thread in native using pthreads. I’ve done that before.
It’s called on the ‘same’ thread. (ie, whatever thread that initiated the call into native/java).
hi
and each update and/or script call is in its own thread or it will lock the game until it cames back?
thanks
Not sure what what you mean by ‘update’; but if you call a native function (or java, which is considered native when coming from scripts) on a particular thread, then it will immediately execute the native call, on that thread. Any other thread will continue to run normally (unless there are other thread locking primitives (mutex/semaphore/‘synchronized’ etc) in play), but obviously the thread making the native call will be ‘blocked’ (as it is performing the call itself).
There is nothing ‘magic’ or different about a native call compared to a managed call to a C#/JS class method in this regard.
i read each script run the “update” function every frame or something like that
the ::Update function is always called on the main thread. If you do native calls (or any calls) on the main thread, the main thread will stall.
what is the best way to make an async call ?
i need to make a call to a webservice and show the result but off cource the rest of the game must be responsive.