Thread Thread aus Tk-GUI heraus beenden (16 answers)
Opened by DonKnilch at 2009-10-19 16:09

DonKnilch
 2009-10-19 16:09
#127139 #127139
User since
2009-09-04
62 Artikel
BenutzerIn
[default_avatar]
Hallo zusammen,

ich habe folgendes Problem:

Ich möchte einen laufenden Thread aus einer Tk-GUI heraus beenden, sobald auf einen bestimmten Button geklickt wird. Leider erhalte ich immer folgende Meldung:

Quote
Tk::Error: Usage: threads->exit(status) at scripts\GUI.pl line 63
Tk callback for .frame2.button1
Tk::__ANON__ at C:/P/site/lib/Tk.pm line 250
Tk::Button::butUp at C:/P/site/lib/Tk/Button.pm line 175
<ButtonRelease-1>
(command bound to event)


Woran kann dies liegen? Der Code sieht folgendermaßen aus:

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
my $Button2 = $frame3->Button  (-text=> "Start",-command =>sub{
my $thread = threads->create(\&startProcessing);
});
my $Button = $frame3->Button (-text=> "Exit",-command =>sub{
my @running = threads->list(threads::running);
foreach (@running) {
my $tid = $_->tid();
print "Killing Thread $tid \n";
$_->exit();
}
exit(0);
});


Vielen Dank schon mal für Eure Hilfe.

MfG
DonKnilch

View full thread Thread aus Tk-GUI heraus beenden