cocoa - Mac sample code using USB and CFRunLoopSource -


i'm trying (re-)write program uses usb controlled scanners. i've got usbiointerfaceinterface set up, can send , receive messages on pipes. calling writepipeto , readpipeto synchronously want read scanner asynchronously.

i've tried using readpipeasyncto, callback never gets called until call timesout. reason appears i'm not registering callback somewhere. if add cfrunlooprun after async read, appears work, having many nested calls cfrunlooprun, can't idea.

i've seen functions:

    err = (*usbinterfaceinterface)->createinterfaceasynceventsource(usbinterfaceinterface, &cfsource);     cfrunloopaddsource(cfrunloopgetcurrent(), cfsource, kcfrunloopdefaultmode); 

but haven't figured out how tell source callback should called when happens on interface. when create source, , call readpipeasyncto, callback doesn't called until timeout.

is there same sample code somewhere can see how these functions supposed work together?

calling cfrunlooprun, or nsrunloop equivalent, sign program's architecture wrong.

it sounds terrible pain do, app better—and work, using readpipeasyncto , writepipeasyncto functions—if rewrote use run loop instead of whatever manual loop have.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -