Re: Updating a TextView with the results of a long, processor-intensive process



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, Apr 14, 2004 at 03:44:57PM -0400, muppet wrote:

Bob Wilkinson said:
On Tue, Apr 13, 2004 at 11:17:21PM -0400, muppet wrote:

On Tuesday, April 13, 2004, at 05:23 PM, Bob Wilkinson wrote:

I have read the FAQ Q: How do i keep my gui updating while doing a
long file read?
and added code to the process_infile routine.
<snip>
However, it only updated my TextView at the end of the processing.


I suspect you're blocking on the read in the IO watch handler.  THis:

               my $line = <$fh>;

is going to try to read until it sees a newline.  I typically do

               local $/ = undef;
               $text = <$fh>;

to avoid blocking there.  The minor disadvantage is that you have to handle a
multiline string, but that's not a big deal.


Just been reading some documentation for setvbuf - used to unbuffer
files in C (for those like me, who don't know), and saw this line.

"System standard streams like stdout and stderr are unbuffered by
default if they are not redirected."

Which may explain why it seems fine when run from the command line -
it just printfs happily, but when I redirect the output to a file -
it looks buffered. 

Fortunately I have the C source code to play with - but that'll be
for tomorrow evening...

Bob
- -- 
When you live in a sick society, just about everything you do is wrong.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAfcQqIiLvYuacGxIRArGRAJ9S7dHrBG/XZHfNm460KebwXSLf3gCeMawz
yDLo7ycqU+dW51q8lV+XaNc=
=2EaI
-----END PGP SIGNATURE-----



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]