Xref: utzoo alt.toolkits.xview:124 comp.windows.open-look:556 Path: utzoo!utgpu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!sdd.hp.com!samsung!uunet!timbuk!ddickey From: ddickey@aspen04.cray.com (Dan A. Dickey) Newsgroups: alt.toolkits.xview,comp.windows.open-look Subject: Re: COME ON G & G! How do I keep a button busy without busy waiting Message-ID: <113651.22184@timbuk.cray.com> Date: 8 Feb 91 18:29:12 GMT References: <1991Feb7.145027.7958@resam.dk> Reply-To: ddickey@aspen04.cray.com (Dan A. Dickey) Organization: Cray Research, Inc. Lines: 45 In article <1991Feb7.145027.7958@resam.dk>, andrew@resam.dk (Leif Andrew Rump) writes: |> I received three (3) answers to my original very interesting post. :-) |> YOU CAN DO BETTER - and I don't accept cheating like making the |> Reset button inactive or changing it to a Reset button, etc.!!! :-( |> |> Well instead of writing the whole thing one more time I'll ask only |> for some suggestions on how to prevent busy waiting if I have the |> following code (stolen from p.400 in Volume Seven of guess what!): |> |> XFlush(dpy); |> while (!reset_pressed) |> { |> notify_dispatch(); |> XFlush(dpy); |> /* Here is the problem - I don't have any code to put here! */ |> } |> |> The reason I don't have any code to put in is that I'm waiting (using |> notify_set_input_func & notify_set_itimer_func) for some input or the |> timer to time out and I'm using this piece of code because I want to |> stay in the callback routine to keep the button that activated the |> callback routine in busy state... |> |> Any suggestions? - Please! Leif (and others), What is the problem with putting in a select() call? I believe this would be the standard solution...do a select() on the file descriptor associated with the dpy. I believe you can use XConnection() to get this (I'm not sure of the name...there is a macro to get it though). Check your return value from select(), you can get a valid return which means there is something for notify_dispatch() to do, or possibly EINTR which means your itimer interruped the select. Oh, also, you may want to put a timeout value in the select() call... Just to be safe. Anyone see any problems with this? -Dan -- --------- Dan A. Dickey ddickey@fizban.cray.com, or ddickey@aspen.cray.com