From: Javier G. <god...@gm...> - 2005-10-19 17:24:13
|
Hello, I have a noobee question, I was unable to find a more appropriate list to post this, please redirect me is this question is inappropriate. I am not sure how to get out of a running thread from a Gtk2 callback, here is the code: ############################# #!/usr/bin/perl -w use Gtk2 '-init'; use strict; use threads; my $keep_running =3D 1; my $thr1 =3D threads->new(sub { =09while ($keep_running =3D=3D 1 ) { =09=09print "Hello\n"; =09=09sleep(1); =09} }); sub button_callback { =09$keep_running =3D 0; =09t$thr1->join; =09Gtk2->main_quit; } my $window =3D Gtk2::Window->new; my $button =3D Gtk2::Button->new ("Quit!"); $button->signal_connect (clicked =3D> \&button_callback); $window->add($button); $window-> show_all; Gtk2->main; ############################# Is there a way to gracefully stop the thread from a callback? Thanks, Javier Godinez |