Sorry if this was already said, but I haven't had time to pay much
attention lately, and this post caught my interest. I originally wrote
this for a program I never released. Some of what it does may or may
not be helpful, just edit it to suit your needs.
ok, heres the simple way to keep your dialog active:
my $total = 0;
my $expected;
my $result = "";
$UA->request(HTTP::Request->new(GET=>'www.whatever.com'),
sub {
my($chunk,$res) = @_;
#Total amount of data downloaded
$total += length($chunk);
#Not important unless you are using the below if statement for
a status or progress bar.
unless(defined $expected){
$expected = $res->content_length || 0;
}
#Add the new data to the old data.
$result .= $chunk;
#In this program, I had a status bar, and I was reporting the
progress on it, could also be used with a progress bar... Remove if not
needed.
if($expected){
$win->StatusBar->Text("Rescieving: $total / $expected");
}else{
$win->StatusBar->Text("Rescieving: $total / ???");
}
#This is the key! Keeps the window alive.
Win32::GUI::DoEvents() >= 0 or exit;
});
I'm afraid I can't go into much detail at the moment to explain it, but
if you have any questions, feel free to ask.
|