0

I have tried to call a function using threads using perl in my windows system.
But, during the execution, when i click the button to create a thread process, Microsoft error message is displayed as shown below,

"Perl Command Line Interpreter. Please tell Microsoft about this problem."

Code Snippet i used in Perl:

use threads;

#####  Creation of a dialog box using Tkx Module #####
$Run = $MainFrame -> new_ttk__button(
          -text => TEXT,
          -width => 15,
          -command => sub
                       {
                         threads -> create({"stack_size" => 64*4096,
                                            "exit" => "thread_only"},
                         \&CALLING_FUNCTION);
                       }
);

1 Answers1

0

It looks like Tk having difficulties with threads: Perl Update UI on Long Thread

You need to create your thread before the Tk objects, maybe it is going to work this way.

However, using threads with Tkx may be dicey. I was getting segfaults when I tried to join the thread rather than detach it, and I get a segfault with the code below if I move my $t inside startWork(). This discussion suggests that you may need to start the thread before creating any Tk widgets for it to work reliably.

Your problem comes because you are letting Tk code get copied into your thread, by starting it late in the script. When a thread gets launched, a copy of the main thread is made, so if there are Tk widgets already in existence, they get copied in. Even if you don't use the Tk code in the thread, it can cause problems, and will be unreliable. So...... create your thread first, before starting any Tk widget code.

Community
  • 1
  • 1
user1126070
  • 5,059
  • 1
  • 16
  • 15