pasturel@sctc.com (Pierre Pasturel) (12/14/90)
I want to use XtAddTimeOut to cause a delay X in msec in a callback by doing this: /*** in callback timer_id = XtAddTimeOut(X,delay_done,NULL); while ( done == FALSE ) { } /* rest of processing in callback */ *** end of callback ***/ void delay_done(caddr_t client) { done = TRUE; } where delay_done is the processing procedure which will set the done flag to TRUE when X msecs have expired. The problem is, the while loop sits in a tight loop forever and the Time Out never occurs. Do you know what I can do? I want to set it up so that processing occurs AFTER the while loop, not in delay_done. Thanks for any help Pierre pasturel@sctc.com p.s. I tried using setjmp and longjmp, but I would rather stay away from those.
rowan@ima.isc.com (Rowan Hawthorne) (12/14/90)
In article <1990Dec13.170905.21902@sctc.com>, pasturel@sctc.com (Pierre Pasturel) writes: |> |> I want to use XtAddTimeOut to cause a delay X in msec in a callback by |> doing this: |> |> timer_id = XtAddTimeOut(X,delay_done,NULL); |> |> while ( done == FALSE ) { |> } |> |> where delay_done is the processing procedure which will set the done flag |> to TRUE when X msecs have expired. The problem is, the while loop |> sits in a tight loop forever and the Time Out never occurs. How about calling XtNextEvent and XtProcessEvent in that loop, instead of having a tight loop? Rowan Email rowan@ima.isc.com Phone 617-661-7474 x206 Fax 617-661-2070 upstream from the last bend in the Charles River
pasturel@sctc.com (Pierre Pasturel) (12/15/90)
rowan@ima.isc.com (Rowan Hawthorne) writes: >In article <1990Dec13.170905.21902@sctc.com>, pasturel@sctc.com (Pierre Pasturel) writes: >|> >|> I want to use XtAddTimeOut to cause a delay X in msec in a callback by >|> doing this: >|> >|> timer_id = XtAddTimeOut(X,delay_done,NULL); >|> >|> while ( done == FALSE ) { >|> } >|> >|> where delay_done is the processing procedure which will set the done flag >|> to TRUE when X msecs have expired. The problem is, the while loop >|> sits in a tight loop forever and the Time Out never occurs. >How about calling XtNextEvent and XtProcessEvent in that loop, instead >of having a tight loop? > Rowan I am no X event expert (actually, I just use XtMainLoop to do the processing for me), but I was reading a little about events and it would appear that it might get tricky if I have a XtMainLoop() in main() and another event loop in a callback waiting for a timer event. Does anyone out there know a clean solution to this where I can keep my XtMainLoop in main() but block waiting in a callback waiting for the event that will be caused by XtAddTimeOut and then continue executing at the point where I blocked waiting on the timer event in the callback?? A sample of code would help. Thanks, Pierre pasturel@sctc.com