Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!think.com!mintaka!bloom-beacon!dont-send-mail-to-path-lines From: asente@adobe.COM Newsgroups: comp.windows.x Subject: Re: Timer Interrupt Keywords: Timer, Event handler Message-ID: <9101241932.AA02468@baskerville.adobe.com> Date: 24 Jan 91 19:32:32 GMT References: <1100@unisql.UUCP> Sender: daemon@athena.mit.edu (Mr Background) Organization: Adobe Systems Inc. Lines: 34 In article <1100@unisql.UUCP> yu@unisql.UUCP (Yeong-Ho Yu) writes: > I am trying to make a main event handler which will run for at least >the given time, and returns the control back to the program. >That is, it should be a temparary XtAppMainLoop. > > I made up the following function: > >void TempEventH(XtAppContext app, unsigned int time) >{ > XEvent event; > > XtAppAddTimeOut(app, time, NULL, NULL); /* put up a timer event */ > while(!(XtAppPending(app) & XtIMTimer)){ /* until it arrives */ > XtAppNextEvent(app, &event); /* do the event processing */ > XtDispatchEvent(&event); > } >} > >Of course, it does not work. But, I don't know why. >Any suggestions? Many thanks in advance. From section 7.4 of the Xt spec, discussing XtAppNextEvent: If the X event queue is empty, XtAppNextEvent flushes the X output buffers of each Display in the application context and waits for an X event **while looking at the other input sources and timeout values and calling any callback procedures triggered by them.** [emphasis added] In other words, your timer is getting triggered in XtAppNextEvent. You need to use use XtAppProcessEvent to get the degree of control over event dispatching that you want here. -paul asente asente@adobe.com ...decwrl!adobe!asente