Article View: borland.public.jbuilder.java.language
Article #17953Re: Processing Windows messaging / Threads
From: Scott Ottesen
Date: Thu, 03 Sep 1998 00:00
Date: Thu, 03 Sep 1998 00:00
53 lines
2664 bytes
2664 bytes
William Yu wrote:
> You need a separate thread to listen for user interface events and
> interrupt the processing loop when necessary. (Interruption can be in
> the form of setting boolean flags that the processing code periodically
> checks against.)
William-
I'm kind of confused with this and can't seem to find any other documentation
on it. I've played around with some multi-threading, but I'm not sure how to
go about plugging a UI listener into a new thread class and still have it
update the components. For example, I have a while loop reading down a
database, taking the contents and dumping it to a text file. As it's reading
each row, I have a TextControl component saying "Exported x Records".
Something like:
while (true) {
if (datamod.queryDataSet.atLast()) {
break;
}
iCount++;
tcExportCount.setText("Exported "+iCount+" records.");
dataOutputStream.println(datamod.queryDataSet.getString("AnyField"));
datamod.queryDataSet.next();
}
Now, the tcExportCount TextControl component will update fine throughout the
rest of the program until it hits this loop! But all refreshing stops until
the loop is complete. (This also holds true for a KLGroup ProgressMeter
component). I've tried refresh(), update(), repaint(), etc on the frame and
components with no positive results. (I'm on JBuilder 2).
I've tried building a thread class that does nothing but run monitoring the
datamod.queryDataSet to know what record is being accessed then having it post
it's information (via passing to the thread the tcExportCount object) to the
UI while the the loop above is running. The thread runs as it should, but
still will NOT update the UI!
I've gotten my cancel button to work this way though, and I appreciate the
help with that!
Any clue where I can look up some examples for UI refreshing?
Thanks again-
Scott Ottesen
sottesen@dced.state.ut.us
or
sottesen@wasatch.com
Technical Details
Message-ID:
<35EEDAA6.BE92CFE0@dced.state.ut.us>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<35CB2F83.C66DE626@dced.state.ut.us> <35CB9EC2.409AB0EB@Bigfoot.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,527fcc360015b0d3 X-Google-Attributes: gidf74b3,public From: Scott Ottesen <sottesen@dced.state.ut.us> Subject: Re: Processing Windows messaging / Threads Date: 1998/09/03 Message-ID: <35EEDAA6.BE92CFE0@dced.state.ut.us> X-Deja-AN: 387563388 Content-Transfer-Encoding: 7bit References: <35CB2F83.C66DE626@dced.state.ut.us> <35CB9EC2.409AB0EB@Bigfoot.com> To: William Yu <William_Yu@Bigfoot.com> Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language