Hello greetings! I would like to trigger run for 2 buttons (or more) at the same time with another button call "RunAll". Each buttons (I call it button1 and button2) have it's own subroutine. I manage to trigger run for this new "RunAll" button to call the button1 and button2 up but it only run one after another, I would like the new "RunAll" button to trigger run in parallel as due to the long run time for one of the button. Can anyone please help me on this?

Below is my code

my $run_all=$mwb_final->Button( -text => 'RunAll', -width => 100, -activebackground => 'blue', -background => 'green', -command => sub { $first_button->invoke(); $second_button->invoke(); #push @jobs, threads->create(sub {$first_button->invoke();}); #push @jobs, threads->create(sub {$second_button->invoke();}); #$_->join for @jobs; # Wait for everything to finish. })->pack();

p/s:I tried with another option of coding as the one which commented out (using threds, and I did put "use threads" on top of my code), but it seems not works for me either. I get errors as below

> Thread 1 terminated abnormally: Can't call method "tagAdd" on an u +ndefined value at /usr/pkgs/perl/5.14.1-threads/lib64/module/default/ +x86_64-linux-thread-multi/Tk/Text.pm line 158. Thread 2 terminated abnormally: Can't call method "tagAdd" on an undef +ined value at /usr/pkgs/perl/5.14.1-threads/lib64/module/default/x86_ +64-linux-thread-multi/Tk/Text.pm line 158. Attempt to free non-existent shared string '_ErrorInfo_', Perl interpr +eter: 0x602010 at /usr/pkgs/perl/5.14.1-threads/lib64/module/default/ +x86_64-linux-thread-multi/Tk.pm line 424.

In reply to How to run 2 buttons in parallel in Perl/Tk by Janish

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.