On Thursday, October 9, 2003, at 12:43 PM, John Cebasek wrote:
> If I'm writing to a pipe with WritePipeAsync(), and have called
> CreateInterfaceAsyncEventSource() to get a run loop source, do I have
> to call CFRunLoop?
Yes. Once you call CreateInterfaceAsyncEventSource(), you'll need to
CFRunLoopAddSource(), and then CFRunLoopRun(). You won't be able to
receive the asynchronous completion of your write command until
CFRunLoopRun() is called.
Here's a snippet of code that I use in a thread built for the
asynchronous notifications. You'll notice that when you call
CFRunLoopRun(), you won't be able to reach the next line of code until
you've stopped the run loop, using CFRunLoopStop(..), which you'll do
from another thread, or by sending an event into this thread and
setting up a handler that will stop the run loop.
// you should store this RunLoop reference in order to stop the run
loop later
CFRunLoopRef runLoop = CFRunLoopGetCurrent();
CFRunLoopSourceRef source;
if (runLoop != NULL)
{
source = (*intfintf)->GetInterfaceAsyncEventSource(intfintf);
if (source == NULL)
{
err = (*intfintf)->CreateInterfaceAsyncEventSource(intfintf,
&source);
if (err || (!source))
{
return err;
}
}
if (!CFRunLoopContainsSource(runLoop, source, kCFRunLoopDefaultMode))
{
CFRunLoopAddSource(runLoop, source, kCFRunLoopDefaultMode);
}
CFRunLoopRun();
}
Make sense?
Kris Daniel
Line 6, Inc.
_______________________________________________
usb mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/usb
Do not post admin requests to the list. They will be ignored.