Confused about CFRunLoop
Confused about CFRunLoop
- Subject: Confused about CFRunLoop
- From: Brian Greenstone <email@hidden>
- Date: Mon, 17 Mar 2008 21:53:13 -0500
I'm trying to convert some old Carbon code over to Cocoa, and one of
the things I'm doing is converting my old run-loop timers. I used to
use the following code:
InstallEventLoopTimer(..);
RunApplicationEventLoop();
..
QuitApplicationEventLoop();
That always worked fine, so now I'm trying to do it this way:
CFRunLoopTimerCreate(..);
CFRunLoopAddTimer(..);
CFRunLoopRun();
Unfortunately, these CF run loops behave differently. When I call
CFRunLoopRun, my timer does fire off like it should, but it appears to
be running in a modal loop where I do not have access to the menu bar,
and my windows no longer receive any mouse click events et.al. So, as
an experiment, I tried replacing the CFRunLoopRun() with:
[[NSApplication sharedApplication] run];
That actually works! My timer fires off like it should, yet
everything else works too. I can still access the menus, and window
still receive click events. Unfortunately, there's no way to exit
that event loop as far as I can tell. I tried this...
CFRunLoopStop(CFRunLoopGetCurrent());
... but that did nothing.
So, can someone explain the correct way to install a Timer, have the
system keep working like normal, and then be able to quit that event
loop from the timer's callback?
Thanks,
-Brian
_______________________________________________
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