# Starten der Messung my $StartButton = $ControlFrame->Button(-text =>"Messung starten", -command =>\&StartThr1)->pack; # Beenden der Messung my $StopButton = $ControlFrame->Button( -text => "Messung beenden", -command=>\&SetKillFlag)->pack; . . . #----------------------- # sub: Measure() #----------------------- # Aufgabe: # Führt eine einmalige Messung aus sub Measure{ #open( DATEI, ">$fileName") || die("Datei $fileName kann nicht geöffnet werden\n"); $ob->write('m'); &_wait; $input = $ob->input; return $input; } #----------------------- # sub: RunMeasure() #----------------------- # Aufgabe: # "Messschleife" sub RunMeasure{ my $stat = $_[0]; my $wait = $_[1]; $count = 0; while( $count < 1000 ) { &_wait; &_wait; &_wait; &_wait; $newValue = &Measure; my $newDraw = $graphYSize/(1<<$resolution) * $newValue; my $oldDraw = $graphYSize/(1<<$resolution) * $oldValue; $lineId = $Canvas->createLine($count,500-$oldDraw,$count+$xShift,500-$newDraw); $count += $xShift; $oldValue = $newValue; print $killFlag; } return; } . . . sub SetKillFlag{ $killFlag = 1; } sub StartThr1{ $thr1 = threads->create('RunMeasure'); $thr1->detach; }