use Tk; my $MW = MainWindow->new(); ... ... $REFRESH{xyz} = \&xyz; ... # The "wait routine" { my ($WidRFR) = $REFRESH{$ID}->(); # Call the function while($CTRL_REFRESH < 1) { select(undef,undef,undef,0.1); } # this waits until the var changes # Do some stuff } ... # The routine with the repeat Object sub xyz{ my $RFR = $MW->repeat( 500, sub{ { $CTRL_REFRESH = 1; # Do some stuff.... if(...) { $CTRL_REFRESH = 2; } # This is to notify the end of the work and it Works } } ); return($RFR); # Pass the object to the caller to make it able to destroy it }; ...