Roger has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use Tk; use Win32::MMF::Shareable; print "Process starting...\n"; my $ns = tie my $wait, 'Win32::MMF::Shareable', 'wait' or die; $wait = 0; my $pid = fork; if (!$pid) { $SIG{HUP} = \&stop; while( 1 ) { print "tick()\n"; sleep 1 } } my $mw = MainWindow->new; $mw->Button( -text => '$wait', -command => sub { pri +nt "\$wait is $wait\n" } )->pack; $mw->Button( -text => 'waitVariable( \\$wait )', -command => \&start ) +->pack; $mw->Button( -text => 'local $wait++', -command => \&stop ) +->pack; $mw->Button( -text => 'remote $wait++', -command => sub{ kill +( 'HUP', $pid ) } )->pack; MainLoop; kill( 'TERM', $pid ); sub start { print "waiting for \$wait (was $wait)\n"; $mw->waitVariable( \$wait ); print "finished waiting for \$wait (is now $wait)\n"; } sub stop { print "\$wait++ by pid $$\n"; $wait++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Tk and waitVariable on tied variables
by ant9000 (Monk) on Feb 16, 2004 at 09:00 UTC | |
by Roger (Parson) on Feb 16, 2004 at 10:37 UTC | |
by ant9000 (Monk) on Feb 16, 2004 at 11:40 UTC | |
by xiper (Friar) on Feb 17, 2004 at 23:56 UTC | |
by Roger (Parson) on Feb 16, 2004 at 12:27 UTC | |
by ant9000 (Monk) on Feb 16, 2004 at 13:41 UTC | |
|
Re: Tk and waitVariable on tied variables
by JamesNC (Chaplain) on Feb 16, 2004 at 22:14 UTC | |
by Roger (Parson) on Feb 17, 2004 at 05:36 UTC |