Since I was looking for something slightly different than Rob had
provided, I managed to make use of his example (TY Rob) and turn it
around into something more 'famliliar'.
Thanks for posting the code - the more feedback and comments, the better the
final solution will be:)
The attached 2 files:
ThreadSafe.pm
Threadsafe_1.pl
The module is built around the idea that there *had* to be a way to get
messages from the windows thread (main aka tid == 0 ) to the child
threads.
Would this be the correct usage of your module:
#Add this after the window has been created
$win->AddButton(
-name => 'test',
-text => 'test',
-pos => [114, 10],
-height => 20,
-onClick => \&butclick,
);
sub butclick {
for (1..5) {
$win->SendMessage(WM_PIPE1,M_DATA,['some data',$_]);
$win->SendMessage(WM_PIPE2,M_DATA,['some data',$_]);
}
}
When the button is clicked, 5 messages are sent to both spawned threads. Is
that correct? Would be correct to say that the essence of your package is
that it allows the main thread to communicate with child threads via the
windows message queue?
Cheers,
jez.