Android Question JobDone not being hit.

Discussion in 'Android Questions' started by Derek Jee, Aug 28, 2015.

  1. Derek Jee

    Derek Jee Active Member Licensed 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.

    Code:
    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
     
  2. RandomCoder

    RandomCoder Well-Known Member Licensed 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.
     
    KMatle and DonManfred like this.
  3. Derek Jee

    Derek Jee Active Member Licensed 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..
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Http requests are always handled in the background (by a pool of threads).

    You cannot hold the main thread.
     
  5. Derek Jee

    Derek Jee Active Member Licensed 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.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    What are you doing in JobDone that slows down the UI?
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice