Android Question how to wait for a Service is started ?

peacemaker

Expert
Licensed User
Longtime User
HI, All

I have already debugged app that works with several Cloud services - now 2.
Each Cloud class module works with corresponding Service module.
And now i need to add 3rd cloud, GoogleDrive (let's say GD).
If to try to make the same way structure - i have to start the GD service were the GD class is declared and all needed subs, events are.

But strange that this 3rd service for GD is starting so slow that i cannot develop in the debug mode.
In Release the service is started fast and it's OK, but ... i need to debug next functions with GD, but Debug mode is ... a trouble now.

Any ideas ?
It seems, i have to wait somehow until the service is started fully...
 

DonManfred

Expert
Licensed User
Longtime User
Raise an event when the service has started.
Wait for this event in the calling activity.

Or set a global var (initialized in starter) when the service has started.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
But the StartService is called from a common sub of the code module - how to raise an event ?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
It's not Starter, it's special service for GoogleDrive class work. But one service among 3 clouds is started from a code module sub. This sub is single, common for usage in several points, so ... it's usually placed into a code module, right ?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
It's not Starter, it's special service for GoogleDrive class work. But one service among 3 clouds is started from a code module sub.
Again: The starter service IS started before any other service or activity!
Define global var in the starter and set the value to TRUE if service x has started. GD service for example change Starter.GDrunning to true when started.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
And how to wait for ... this var is changed ?

B4X:
    Do Until Starter.GD_Service_isStarted
        Sleep(0)
    Loop
?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Ohhh... Sleep(x) allows next running, so next subs are called, but no service is started yet.
It needs to make fully synchronous ...
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Thanks, but .... the topic question is still open.
And it seems, the only way is use the Starter service as the common start sub container, with Wait for ...Event from the starting service.
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
Upvote 0
Top