Refreshing stuff in the background ( continued )



Hi all.

Following on from my previous email, I've broken up all the code that
refreshes various notebook pages into separate subs. I've made an array
of hashes describing each page, and with a coderef to the sub that does
the requerying for that page.

The main bit of code that triggers everything is:

sub refresh_pages {
   
    my $self = shift;
   
    # Refresh the active page immediately
    my $active_page =
$self->{form}->get_widget("TabForm_main_notebook")->get_current_page;
   
    print "Refreshing page: $self->{refreshers}[$active_page]->{name}\n";
   
    $self->{refreshers}[$active_page]->{refresh}();
   
    my $counter = 0;
   
    foreach my $refresher ( @{$self->{refreshers}} ) {
    if ( $counter ne $active_page ) {
        print "Refreshing page: $refresher->{name}\n";
        $refresher->{refresh}();
    }
    $counter ++;
    }
   
    Glib::Source->remove( $self->{refresh_timeout} );
   
}

 ... and I trigger this code with the line:

$self->{refresh_timeout} = Glib::Idle->add ( sub { $self->refresh_pages } );

This code runs fine - ie it refreshes all the pages. However, even
though the window is 'responsive' ( ie redraws ), nothing actually
updates until ALL the pages are refreshed. So when I run the app from an
Eterm, I see the lines:

Refreshing page: xxx
Refreshing page: yyy

etc

and when the *final* one prints, *then* the window is actually updated
with the new data.

What am I doing wrong?

-- 
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: dkasak nusconsulting com au
website: http://www.nusconsulting.com.au



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