Android Question JobDone not being hit.

Derek Jee

Active Member
Licensed User
Longtime User
Hi there

I have a routine which is sending batches of HTTP requests. I send a pre determined number of them and loop whilst waiting for the results with a DoEvents in there to stop UI issues. I am finding that the JobDone event is not being fired when I call the routine sending the request. I have written a brief psudo code of what I am doing. Can anyone advise how I get the JobDone to fire? I am guessing the loop is never queuing the JobDone but I do not know..

Thanks for the help,


Derek.

B4X:
Do While ItemsLeft <> 0
      DoEvents
      Select Records from table
             Loop through them
                    Update record set flag to 'being requested'
                    CallSub2(SendHTTPRequest, "SendHTTP") 
       ItemsLeft = Count how many left to send
Next

I have also used CallSubDelayed
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
Please see this post which will explain that you need to do... RDC many jobs on one activity - jobdone issue
Basically you have to initiate the http request then wait for the job done event to occur, after which you can call the next request or continue with the rest of your logic. You cannot hold the Main thread in a loop and expect the result to still come in. This issue has been covered many times in the forum.
 
Upvote 0

Derek Jee

Active Member
Licensed User
Longtime User
Thank you for your response. Is there a solution to this using a separate thread or will I have the same problem? I have been asked to do a number of requests asychronously. But am beginning to understand that it may not actually matter if my end result is the same.. Except of course one by one would be slower potentially..

Thank you..
 
Upvote 0

Derek Jee

Active Member
Licensed User
Longtime User
Thanks Erel, my problem is with the processing of the responses. I am being asked to process these immediately they come in without halting the UI. If looping through requests by processing the next one in the previous one's jobdone is the only way then I'd like to know that. If it is not and a separate thread can handle looping and picking up responses without hanging the UI then great..

Kind regards,


Derek.
 
Upvote 0
Top