|
From: Perl R. <pe...@co...> - 2008-11-06 16:52:21
|
Hi all,
Am I susceptible to a crash if I create a Win32::GUI object (such as a
label) in one thread, then call methods on that object in another thread?
Following is an example of what I mean. Notice that I'm passing the label
object as an argument to the entry point function of the new thread. This
seems to work, but I don't know if I should be doing it just because it
works:
use strict;
use Win32::GUI();
use threads;
my $main = Win32::GUI::Window->new
(
-name => 'Main',
-text => 'Template Window',
-size => [300,300],
);
my $label = $main->AddLabel
(
-text => 'I like the number 10',
-pos => [10,10],
);
threads->create('countDown', $label);
$main->Center();
$main->Show();
Win32::GUI::Dialog();
sub countDown
{
my $labelObject = shift;
for (my $i=9; $i>0; $i--)
{
$labelObject->Text("I like the number $i");
sleep(1);
}
}
Thanks,
Rob
|