Mailing Lists: Apple Mailing Lists

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

Re: Problems with timers & events




On 9-aug-07, at 21:00, Andreas Falkenhahn wrote:

I'm new to Mac OS X programming so please bear with me :)

For a newbie you are doing some smart stuff, but it is unusual indeed.

The main loop of my application then looks somewhat like the following:

for(;;)
{
 dostuff();
 waitevents();
 handleevents();
}

I found out that when a timer fires, no event is generated.

I suppose your timer limits the time that waitevents may wait?
You also need to make sure dostuff returns often enough, assuming handleevents serves to keep the interface responsive.


Eric Schlegel wrote:
There's a better way: use QuitEventLoop( GetMainEventLoop() ) from
within your timer function. This will cause the ReceiveNextEvent call
to return immediately.

Yes, but then he has to call RunApplicationEventLoop and QuitEventLoop once per loop iteration.
What if events are generated while the event loop is not run? Does the main event queue persist in the meantime?
I think the dummy event approach is quite nice.


Jan E.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/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.