I’m in this case:
Component A (use B api function)
Component B (exposes api functions)
Component B handle “Data Connection”, it open GPRS context and activate data. I use built in ` le_data_ConnectService() and then le_data_Request() for this. Naturally if connection is down, Component B can take time to ativate.
Componet A, instead, watch for some events (motion) and if needed it call Componet B for connection.
My question is, how to avoid blocking A while calling B apis during works?
Sorry for my questin but i cant find a clear documenation on this. I’ve tried calling B methods from A using thread but got a problem here… cause the le_data_ConnectService(); needs to be called from the main thread. So i Receive an error.
Thank you so much,
Then can you using other higher priority thread to handle motion event in component A?
You say that “le_data_ConnectService(); needs to be called from the main thread”
Then you can create other thread to handle motion event, right?
Yes, from component A i can create a Thread to alert Component B that “data connection” is needed, and i can set this to high priority. But anyway … when calling B api… (Connect)… in this function i call le_data_ConnectService(), and it goves me an error: le_data_ConnectService must be called from main thread…
The only way i found is using a Timer in B to check is something changes… and start actions based on some variable changed. I’m using this approach in another component… but this fill the code of timers…
Then why don’t you call le_data_ConnectService() in the main thread?
if calling in main thread means calling a direct function from extern, via a method… then this will block until connection established. And I dont want this, cause this will block other part of code that must flow normally without wait…
Other part of code should be run in another higher priority thread, not same main thread
will try to make some changes following your direction…
thank so much … you really kind.