Possible Duplicate:
How would you implement a basic event-loop?
Not really a language-specific question. What could be an efficient implementation of event loop? So far I've only encountered something like this:
while (true) {
handleEvents();
sleep(100);
}
which I don't think is the best way - if sleep duration is too short, it will eat lots of cpu, and if it's too long, the app will be pretty unresponsive.
So, is there a better way?
Thanks