Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Guidance for doing USB reads on a separate thread



Hello,

Right now my cocoa application can read from the USB port and do exactly what i need it to do, except for the fact that while it is reading from the USB port everything else freezes, waiting to return from the RunLoop. I have based my USB code on the USB SImpleExample. In the end I want it to read from the USB port and write what is read to a file, while the user can still perform some simple functions on the UI of the application.

So, first of all, is there any way to add the ReadAsync notifications to the cocoa application's RunLoop without explicitly having to call CFRunLoop and wait for it to return? It seems that the cocoa application must already have it's own runloop?

If not, i'm thinking I need to just fire up another thread to do all the USB reading/writing to disk. I know the basics of NSThread, but I am unsure how to mix the USB code with a new thread. Should all the USB initialization be done on the separate thread, or can I initialize the USB(open ports, configure device, etc) on the main program and then just spawn the thread when I need to read?

I'm sure this has been done before, so generally how should I do this?

Thanks,
Juan

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/usb/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.