in reply to Re: Perl::Gtk2, Looking for a Widget Similar to HourGlass
in thread Perl::Gtk2, Looking for a Widget Similar to HourGlass
sub submit_function() { print "YOU CLICKED SUBMIT...\n"; print "Run Background Job... And Open 'Loading...' Pop-Up Window\n"; $popup_window->show_all(); my $command = "/path/to/command/test_backgroundProcess.pl"; ### Start running the Background Job: my $proc = Proc::Background->new($command, "5"); my $PID = $proc->pid; my $start_time = $proc->start_time; my $alive = $proc->alive; ### While $alive is NOT '0', then keep checking till it is... # *When $alive is '0', it has finished executing. while($alive ne 0) { $alive = $proc->alive; # This while loop will cause Gtk2 to conti processing events, if # there are events pending... *which there are... while (Gtk2->events_pending) { Gtk2->main_iteration; } Gtk2::Gdk->flush; usleep(1000); } my $end_time = $proc->end_time; print "*Command Completed at $end_time, with PID = $PID\n\n"; # Since the while loop has exited, the BG job has finished running: # so close the pop-up window... $popup_window->hide; # Get the RETCODE from the Background Job using the 'wait' method my $retcode = $proc->wait; $retcode /= 256; print "\t*RETCODE == $retcode\n\n"; ### Check if the RETCODE returned with an Error: if ($retcode ne 0) { print "Error: The Background Job returned with an Error...!\n"; } else { print "Success: The Background Job Completed Successfully...!\n"; } }
|
|---|