ntubski is right.
The "ideal" solution will vary, but the basic idea is correct:
1. Polling is bad
2. You should always avoid polling by blocking.
Here, that means blocking on XNextEvent ()
3. If you want to do something periodically, you should set up some kind of "event" that will "signal" you at the right time.
Ntubski's suggestion about setting up an OS-level timer is a good idea.
If you're using Xt, Qt or GTK, you could use one of their timers. If you felt like spawning a thread, you could could put your "sleep()" there. There are *lots* of alternatives.
'Hope that helps .. PSM
PS:
Did I mention "Polling is Bad"? It *is* bad. "Evil", in fact. Honest!
|