[comp.windows.x] `Sharing' with XtAppMainLoop

bradd@csd.uwo.ca (krusty the klown) (03/01/91)

I'm just getting my feet wet in X-window development, so here's another
question:

I would like to have my program keep cranking away while XtAppMainLoop
is in action.
I came up with the following solution, but I'm sure that there are
better ones:

  Before starting XtAppMainLoop, call XtAppAddTimeOut with an interval of
  1 millisecond.
  Call XtAppMainLoop.
  Every time the procedure from XtAppAddTimeOut is called, restart the
  timeout with another call to XtAppAddTimeOut.

This appears to work, but I'm sure there is a better way.
The smallest possible timeout of 1 millisecond doesn't seem to quick;
ie: my program
running in the "background" seems a little slow.

BTW, I'm using the Athena Widget Set.
Thanks.

Patrick Bradd                                     bradd@csd.uwo.ca

colin@nbc1.ge.com (Colin Rafferty) (03/05/91)

In article <1991Feb28.162008@csd.uwo.ca> bradd@csd.uwo.ca (krusty the klown) writes:
> I would like to have my program keep cranking away while XtAppMainLoop
> is in action.  I came up with the following solution, but I'm sure
> that there are better ones:
>   Before starting XtAppMainLoop, call XtAppAddTimeOut with an interval of
>   1 millisecond.
>   Call XtAppMainLoop.
>   Every time the procedure from XtAppAddTimeOut is called, restart the
>   timeout with another call to XtAppAddTimeOut.

There is an easier and "better" way of doing this.  Simply use the
XtAppAddWorkProc() call that's defined in the Xt Toolkit Intrinsics
book on page 91.  This will have XtMainLoop call the procedure itself
and you don't have to worry about timeouts and stuff.

Just make sure that the procedure doesn't do too much (which you
should already be doing).  If you don't, your user will get very
upset.

-- 
Colin Owen Rafferty              |      I believe in compulsory cannibalism.
colin@nbc1.ge.com                |      If people were forced to eat 
(I don't speak for NBC.          |      what they killed, there would
Watch Tom Brokaw for that.)      |      be no more wars.      -- Abbie Hoffman