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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |