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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to