09-13-2010 10:07 AM
Is there a good example out there where this is shown? What I am interested in is a class (set of classes) that allow you to post a request and then "wait" for the result. I have an app that does a variety of things with web services and keeping this all threaded properly is a bit of a challenge...
I realize that all the internet stuff cannot run on the main event thread...
09-13-2010 10:17 AM
most of the time i use a callback structure to notify my UI about new results.
you can use a new thread for each request, or, i bigger structures, use a runnablequeue.
09-13-2010 10:23 AM
To create a well defined structur, you can use this approach:
Create HTTPCommunicationInterface class which would have methods like StartRequest, CancelRequest
Create HTTPCommunicationImplementation which implements HTTPCommunicationInterface and Runnable. In this constructor, you can create a new thread object, and in overwrite method StartRequest- you can start the thread. In the run method you can actually write SendPostRequest method, which will run in seperate thread without interupting main event thread.