Threads and Gtk2
- From: Javier Godinez <godinezj gmail com>
- To: gtk-perl-list gnome org
- Subject: Threads and Gtk2
- Date: Wed, 19 Oct 2005 11:28:49 -0700
Hello,
Is there a way to gracefully stop a thread from a Gtk2 callback by
using a global?
I am not sure how to get out of the running thread as shown here:
#############################
#!/usr/bin/perl -w
use Gtk2 '-init';
use strict;
use threads;
my $keep_running = 1;
my $thr1 = threads->new(sub {
while ($keep_running == 1 ) {
print "Hello\n";
sleep(1);
}
});
sub button_callback {
$keep_running = 0;
$thr1->join;
Gtk2->main_quit;
}
my $window = Gtk2::Window->new;
my $button = Gtk2::Button->new ("Quit!");
$button->signal_connect (clicked => \&button_callback);
$window->add($button);
$window-> show_all;
Gtk2->main;
#############################
Any help will be greatly appreciated...
Thanks, Javier Godinez
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]