Hi,
I’m parsing an xml document (search/modify some attributes, etc…) and this requires quite a bit of time… I’d like to move all of the parsing operations into a separate thread and in the meantime update the screen with a progress bar.
Is possible to achieve it with ofThread?
Namasté
PS: (I’m quite used to Android where I would use a simple asyncTask object which has the onProgressUpdate() method and the doInBackground() and onPostExecute() )
Hi,
I am not an expert in OF but i feel this could be done.
here is possible solution,
have a separate thread which does xml parsing, update the main gui thread using ofEvents . refrence, there are good examples related to ofEvents , may be that will give you good idea.
In the main gui thread’s void draw() check whether you have anything to update .
(checking for update in GUI thread’s draw() is like android’s onProgressUpdate() ,
doing xml parsing in separate thread is like doInBackGround(),
)
with this you can achieve asyncTask’s functionality.
Thanks @Arun_sh!
I’ll surely give a look at ofEvents, they seem quite useful.
Currently I’m trying https://github.com/bakercp/ofxTaskQueue which I found very intuitive and easy to play with.
glad to help . ofxTaskQueue looks good , but it feels like over kill, if you just want to update progress . ! you are adding whole new addon just for this !. it is better to know the alternatives.