Custom Code : RunJavaCode in Threading

0 votes

Hi Again,

i want to ask about RunJavaCode without callback on Unity.

here's my code :

for(int i = 0 ; i < 3 ; i ++)
jResult = customCodeService.RunJavaCode(_name,_json);
resultRunJavaCode = jResult.ToString();
catch(Exception ex)
if(!ex.ToString().Contains("Bad Request"))
exception = ex;
i tested this code in case my connection disconnected.
for the 1st attempt, run java code will trigger exception, so i can determine the connection is failed and suggest to user to retry.
when user trying to retry the connection (2nd attempt) my code stuck on runJavaCode. it doesnt trigget the exception and cannot execute command below it.
after i read about runJavaCode, i think this connection got trap on exception and do looping. so i can't decide the connection is success or not.
any suggestion for this?
i think it would be nice if you add setTimeOut for RunJavaCode, and if time execution reach timeOut limit, it will trigger exception.
note : i'm not using RunJavaCode with callback, because i need to run the code in thread. my data that transferred is encrypted. so i need decrypting the data in thread.
Thank You
asked Jul 11, 2014 in App42 Cloud API-BaaS by goldglorygirl (55 points)

1 Answer

0 votes

It is not recommended to use sync method in Unity platform. We will be depricating our sync method in coming releases as it is not supported on all unity platform and discouraged to use it. Would recommend you to use async method instead and let us know if you have any issue there.


answered Jul 11, 2014 by ajay123 (899 points)
i have used async method before,
but it cause freeze (for a while) on my game.

my custom code transferred data in encrypted text. so the data will have a bigger size than the original data. (i think thats why my screen got freeze)

if i'm using sync method, there's no freeze screen on my game. but it has a problem on disconnected connection.

sync method have more benefit to me, i can decrypting and checking my data on thread before pass final result to main thread.
We will check the sync method on stated scenario and update you on this.
is that any progress?
not replicated at our end. Requesting you to please change your code to async call and let us know if you still face any issue.
what do you mean "not replicated at our end" ?
i can't using async method. because it makes my game screen freeze for a while when getting big data.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on