Placing onExtensionResponse into a thread

Post here all your questions related with the SmartFoxServer iPhone API

Moderators: Lapo, Bax

MrMooMoo
Posts: 18
Joined: 08 Nov 2009, 11:46

Placing onExtensionResponse into a thread

Postby MrMooMoo » 16 Nov 2009, 19:52

Basically, I'm finding numerous places where I call SendXtMessage within a function only to have to drop out to wait for the onExtensionResponse to get called. After this I then need to pick up where I left off within the previous function and all of this is starting to get messy.

I could write my own generic callback system to deal with this but wondered whether anyone has considered/tried putting some of the iPhone API calls (in particular onExtensionResponse) into a separate thread so that after sendXtMessage is called I can simply sit in a loop with the busy icon until the response comes through (or is this a bad way of dealing with iPhone dev?).

Ta,
Moo.
MrMooMoo
Posts: 18
Joined: 08 Nov 2009, 11:46

Postby MrMooMoo » 22 Nov 2009, 15:38

I've come up with a solution. Instead of looking into Threads I simply implement the onExtensionResponse callback into each of my Controller views. This makes things far more elegant.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 07 Dec 2009, 11:47

I could write my own generic callback system to deal with this but wondered whether anyone has considered/tried putting some of the iPhone API calls (in particular onExtensionResponse) into a separate thread so that after sendXtMessage is called I can simply sit in a loop with the busy icon until the response comes through (or is this a bad way of dealing with iPhone dev?).

In general I don't think it's a great idea. I am no iPhone expert but in general running thread is an expensive operation and I would expect it to be even more expensive on portable devices.

Since the time between a request in its response can be a few hundreds millisecond you might end up creating Threads for just a fraction of a second.

Your second idea seems to be best one.

Just my 2c :)
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “iPhone Objective-C API”

Who is online

Users browsing this forum: No registered users and 6 guests