Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!elroy.jpl.nasa.gov!swrinde!mips!apple!well!bschoen From: bschoen@well.sf.ca.us (Brook Schoenfield) Newsgroups: comp.windows.x Subject: Re: Event Loops Message-ID: <24267@well.sf.ca.us> Date: 17 Apr 91 16:50:18 GMT References: Distribution: na Lines: 36 malbert@jeeves.shearson.com (Marc Albert) writes: >I have an application that has multiple top level windows. The event >loop looks something like this: > for (;;) { > if (XtAppPending(WindowOne)) > XtDispatch(); > if (XtAppPending(WindowTwo)) > XtDispatch(); > } >This method works fine. The only problem I have is that >I have to poll for events; this means I am never really >waiting (blocking) and I am burning a lot of CPU. XtAppPending() returns whether or not an event is avaliable: why not use XtAppNextEvent(), which blocks until an event is available? If you need to do processing while waiting for user events, you can set up a timer event and callback to do the background processing. Do not use idle events: they will be sent as fast as the machine upon which you run can go: thus putting you right back to the same place. Happy Coding Brook Schoenfield bschoen@well.sf.ca.us "How can our technology be used to create a peaceful, well fed world?" - burning question