Re: design pattern for data acquisition in background thread?
Re: design pattern for data acquisition in background thread?
- Subject: Re: design pattern for data acquisition in background thread?
- From: Michael Atwood <email@hidden>
- Date: Sat, 27 Sep 2008 13:23:25 -0400
I believe the Design Pattern you're looking for is the Asynchronous
Callback. Basically you send a command over the network and some
point in the future it tells you when the data is available. This
leaves the rest of the application to continue on until your data
request shows up. I'm still learning the Cocoa APIs, but I'd be
surprised if CFNetwork didn't support this functionality since non-
blocking network communication is generally the norm.
-Michael
On Sep 26, 2008, at 6:37 PM, Joe Keenan wrote:
I have an application that acts as a GUI front end for a network
device. The device has a telnet server, so I'm using a ASyncSocket
to open a connection and talk telnet commands to it. That's all
working fine. The problem is that the UI is totally unresponsive
while it's doing an update, and it's 25 or so round trips to the
server (telnet command/responses) for each update.
Right now, the app controller object sends a message to the device
controller, requesting the value of a specified variable. The
device controller does the telnet command to get it, returns it to
the app controller, and the app controller sends it to the text
field. Repeat 25 times for a full update. Slow, and there's no
return to the run loop in there to allow for keyboard or UI events.
I'm looking for suggestions on how to deconstruct this to get the
object talking to the device into another thread so the main window
can take UI events. I'm thinking I can package up the variable
requests into a dictionary so that the device controller can do a
bunch at once. Then the main thread can do all the updates from the
dictionary, which should be quick.
joe
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden