in reply to Structure (timer) calling a method regularly in case of inactivity
#!/usr/bin/perl use warnings; use strict; use Glib; my $main_loop = Glib::MainLoop->new; my $count = 1; my $timer = Glib::Timeout->add (1000, \&timer_callback, undef, 1 ); sub timer_callback{ $count++; print "$count\n"; return 1; # return 0 to stop timer } my $count1 = 1; my $timer1 = Glib::Timeout->add (100, \&timer1_callback, undef, 1 ); sub timer1_callback{ $count1++; print "\t$count1\n"; return 1; } ### filehandle watch open (FH, "+> test.log") or warn "$!\n"; Glib::IO->add_watch (fileno 'FH', ['in'], \&watch_callback, 'FH', 1 ); $main_loop->run; #################################################################### sub watch_callback { my ($fd, $condition, $fh) = @_; my @lines = <FH>; print @lines; #always return TRUE to continue the callback return 1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Structure (timer) calling a method regularly in case of inactivity
by Iceman1884 (Initiate) on Jul 28, 2007 at 13:41 UTC | |
by smithers (Friar) on Jul 28, 2007 at 17:14 UTC |