But I can see from your example that you are starting the thread from a Wx button callback:
The general rule is to start the thread BEFORE any Wx gui code is invoked. So you may try something likeEVT_BUTTON($self,$self->{button_start}, \&DeployTestThread );
then your button callback will just set the shared variable# Prevents double detach attempts my $DETACHING :shared; #start your thread here before Wx DeployTestThread(); package MyApp;
That's the idea, of course you need to setup $TERM properly. But that is the general idea of how to start the thread before the gui code, then use the gui to change a shared variable, which controls thread state.EVT_BUTTON($self,$self->{button_start}, sub{ $TERM = 0 } );
For what it's worth, Perl/Gtk2 has a thread safety mechanism, and you can do what you are trying to do in Gtk2. Also, when Wx builds itself, it will use Gtk2 or Xlib as it's base objects. So if your Wx was built on Gtk2, you may be able to invoke the Glib thread safety mechanism in Wx. You will need to search the docs, or ask someone more knowledgable than me about Wx.
In reply to Re^4: Wx subs and threads
by zentara
in thread Wx subs and threads
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |