Re: Threads and Gtk2



#!/usr/bin/perl -w

use Gtk2 '-init';
use strict;
use threads;
use threads::shared;

my $keep_running : shared = 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;



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