Cool

I installed Perl 5.8 and program crashed right away.  But that was because
the ppm I used for Win32::Gui was for Perl 5.6.  For some reason there is
no ppm for Perl 5.8 on the SourceForge.net web site, at least I didn't see
one.  Looked through the archives and found it on
http://perso.club-internet.fr/rocherl/Win32GUI.html .  Any reason why it's
not on SourceForge, and on the other site?  The script you gave me worked,
and the test script I created worked.  So I will re-write the actuall
program with ithreads and see what happens, I don't think their will be any
problems.  The note you had about using detach should not be a concern.
The thread should always quit before the program does unless the person
using this program decides to kill it prematurely.  But that's their fault
not the programs, ie PIBSAK error.  Hopefully PerlAPP will make an error
free executable.

Thank you Trevor for all your help, it is greatly appreciated.  I would
also like to thank everyone else who helped on this.  I learned a lot about
fork() and process threads.

Joe

Side note.  When I ran Trevors script I got the following message:
Win32::GUI: the -style option is deprecated! at
C:/Perl/site/lib/Win32/GUI.pm line 524.

What are we suppose to use in place of style to get things like scroll
bars.



                                                                                
                                             
                    "Garside,                                                   
                                             
                    Trevor"              To:     <[EMAIL PROTECTED]>            
                          
                    <[EMAIL PROTECTED]       cc:     
<perl-win32-gui-users@lists.sourceforge.net>                                
                    m>                   Subject:     RE: 
[perl-win32-gui-users] Unresponsive Window                         
                                                                                
                                             
                    04/02/2003                                                  
                                             
                    04:27 PM                                                    
                                             
                                                                                
                                             
                                                                                
                                             




Joseph,

I am having the same crashing problem as you.  However, I have a solution!
Instead of using fork(), which is implemented using ithreads, just use
ithreads.

The code below requires Perl 5.8 or higher.

### Begin Source

use Win32::GUI;
use threads;

use vars qw( $Main );

$Main = new Win32::GUI::Window(
     -name   => "Main",
     -text   => "Thread Test",
     -width  => 500,
     -height => 350,
     -left   => 100,
     -top    => 100,
);

$Main->AddButton(
     -name   => "Button",
     -text   => "Create Thread",
     -align  => 'center',
     -valign => 'center',
     -left   => 350,
     -top    => 10,
);

$Main->AddRichEdit(
     -name => "RichEdit",
     -left => 10,
     -top  => 50,
     -width => $Main->ScaleWidth-20,
     -height => $Main->ScaleHeight-70,
     -style => WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_LEFT | ES_MULTILINE
| ES_AUTOVSCROLL,
);

$Main->Show();

Win32::GUI::Dialog();

sub Main_Terminate {
    return -1;
}

sub Button_Click {
           threads->create(\&Do_Stuff)->detach;

           # Note:  by using detach() above, I am (falsely) assuming
           # that this thread will quit before the program does

           return 1;
}

# Call this with a thread
sub Do_Stuff {
           $Main->RichEdit->ReplaceSel("Child thread $$ started.\r\n");
           sleep(1);
           $Main->RichEdit->ReplaceSel("Child thread $$ exiting.\r\n");
           return;
}

### End Source


By the way, the bounce-back message you are getting from this list is just
from some random list subscriber whose account does not allow the email to
go through.

Trevor S Garside
[EMAIL PROTECTED]


> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, April 02, 2003 3:04 PM
> To: Garside, Trevor
> Cc: perl-win32-gui-users@lists.sourceforge.net;
> [EMAIL PROTECTED]
> Subject: RE: [perl-win32-gui-users] Unresponsive Window
>
>
>
> The code is below.  This is the code I'm working with to try
> and figure out
> how to get fork to work.  But it is pretty much the same as
> my production
> code (same problem) except instead of going to sleep it does
> something that
> takes several minutes to run, and the window has more objects
> and looks
> nicer (but that isn't really important).  You can change the
> value of the
> $howlong variable to decide how long it will sleep.
> Basically just click
> the button and then do things to the window or on the
> desktop.  At the very
> least you will get a memory error when you exit the program.
> But sometimes
> you will also get it after the child process finishes.  I
> found an example
> of a fork script that included several clean up (kill the
> child process
> when it was done, etc...).  I used it to write a script that
> would just
> call one child process and then quit, it worked fine until it
> was added to
> a script that uses Win32::GUI.  There must be one additional clean up
> process that needs to be done, I just don't know what it is.
>
> The reason that I didn't cc to the mailing list is because
> the last two
> times I got an automated message from the admin of the mail
> list that read
> the email was a possible Spam letter and that it would not be
> sent.  But it
> was sent anyway.  I replied back asking why I got the message, but I
> haven't heard back from anyone.  I'll cc the mail list,
> hopefully it was
> just a glitch.
>






Reply via email to