in reply to Unresponsive Perl Tk GUI when using system() calls
You are like the Sourcerer's Apprentice, :-) Threads by themselves don't magically make system calls non-blocking. You need to read deeper, and see that the system call needs to be run in a thread. This is called "blocking the Tk eventloop". See the Tk Event Loop
You might run your non-blocking code like this simple thread example. See, your system call is in the thread.
That is about as simple as I can explain it, of course, real code is usually a bit more complicated.
#!/usr/bin/perl use warnings; use strict; use threads; my $thr = threads->new(\&sub1); print "thread running now\n"; $thr->join(); # wait for trivial thread to finish # and return sub sub1{ system("documentation.doc"); print "Done in thread\n"; }
|
---|