Adding wxWidgets to existing app

GyroTech gyrotech at freakinabox.com
Sun Jan 6 05:49:42 PST 2008


Vadim Zeitlin wrote:
>  The question is when does SDL_PollEvent() return? If it does it
> immediately (when there are no events), then this loop will consume 100% of
> the CPU time which is not ideal.
[snip]
>  It's a decent way of doing things but you need to ensure that you block
> somewhere until the next event arrives instead of always cycling in a tight
> loop.

Yes, SDL_PollEvent() is pretty much the equivalent of Pending(), 
returning 0 if no events are waiting. There is a blocking version, but I 
hesitate to use it as if there are no SDL events, execution would not 
continue and Pending() wouldn't be checked until an SDL event occurred.

>  Why do you want to do this? Dispatch() will call the event handler on its
> own...

Yes, sorry, late-night thinking at work. I was used to the old MFC way 
of doing things with PeekMessage() etc. I got some sleep, read up a bit 
more and know just to add a handler function for what ever event I want. 
Speaking of which, I'd better start reading the custom events tutorial 
on the wiki :-)

Thanks a lot.




More information about the wx-users mailing list