On Fri, 2004-29-10 at 15:32 -0500, Jerry Haltom wrote:
> In SWT, one creates a Runnable, and uses the Display object to add it to
> the main loop. When the main loop next cycles, it runs it.
>=20
> Good for multi-threading. You can have a thread in the background which
> passes events to the Gtk main loop.
It seems that one does this:
CustomEvents.addEvent(new Runnable() {
public void run() {
// code to update the GUI goes here.
// eg, I keep a static reference to the
// instance to make it easy to call things.
MyProgram.ui.someUpdateMethod(args);
}
});
Instruction from Mark Burgess was that it is *absolutely necessary* to
do GUI updates from within the Gtk main loop; these "CustomEvents" are
called by java-gnome's gtk main wrapper.
Having tested all this, I can confirm by observation that if you don't
do it this way, the main loop will miss updates (because of different
threads getting called and switched in various random sequences).
I do all this from a worker thread. I have an example of all this
posted:
tla register-archive http://research.operationaldynamics.com/arch/hacks/
tla get an...@op...--hacks/geode--trunk--0.3 geode
cd geode
make [java|native]
(you'd probably have to fiddle with the exact library paths in the Makefile=
)
AfC
Toronto
--=20
Andrew Frederick Cowie
OPERATIONAL DYNAMICS
Operations Consultants and Infrastructure Engineers
http://www.operationaldynamics.com/
|