|
From: Octavian R. <ora...@gm...> - 2008-11-06 19:58:38
|
I thought only the main thread can be used to create GUI elements reliably.
Isn't that true?
Octavian
----- Original Message -----
From: "Perl Rob" <pe...@co...>
To: <per...@li...>
Sent: Thursday, November 06, 2008 6:52 PM
Subject: [perl-win32-gui-users] Threads
> 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
>
>
--------------------------------------------------------------------------------
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the
> world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
--------------------------------------------------------------------------------
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Per...@li...
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
|