Android Question Threading after jobdone

Derek Jee

Active Member
Licensed User
Longtime User
Hi there..

I need to process the response to a http request in a separate thread. I will receive some json and parse it, then add it to a table in my database. This all needs to be done using a single thread. I have tried using the threading lib but it does not run the sub and process the data. Can anyone supply a little bit of code to help me out?

Thanks..

Derek
 

stevel05

Expert
Licensed User
Longtime User
You won't be able to update the Table (or anything else in the Gui) from within a thread, you'll need to delegate that to a sub on the main thread using the Threads RunOnGuiThread method.
 
Upvote 0

Derek Jee

Active Member
Licensed User
Longtime User
Hi Steve

Thanks for the reply. So to clarify, I cannot process my response from a http request in a new thread? Processing data from the downloaded files well halt the UI.. Isn't that what the threading lib is enabling me to do or am I missing the point?

Kindest regards

Derek
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Yes, you can process the responses, just not update the Gui with the results. You will have to call a sub outside of the thread to do that.

See the attached example.

Note: you cannot debug an application that uses a thread, this will only run in Release mode.
 

Attachments

  • ThreadExample.zip
    7.4 KB · Views: 104
Upvote 0
Top