Steve,

SOme complete test code below.
Please try to compile it with perl2exe to produce the error
twice, the first time without modifications, then uncomment the
line use Win32::API
I also produced the error when using the line  threads->tojoin

# Code start


#==========================================================
$| = 1;
#print "Content-type: text/html\n\n";
#use CGI::Carp qw(fatalsToBrowser); 
#==========================================================
use threads;
use threads::shared;
use Thread::Running;
use LWP::UserAgent;
use attributes;

use WIn32::API;
#use Win32::FileOp;
#my %Result;
#my %Done;
share %Result;
share %Done;

#==========================================================
use Win32::GUI;
$MW = new Win32::GUI::Window(
    -title   => 'hello.pl',
    -left    => 100,
    -top     => 100,
    -width   => 400,
    -height  => 200,
    -name    => 'MainWindow',
    -visible => 1,
);

$PrintMsg = $MW->AddLabel(
       -text    => "Processing:",
       -name    => "ProcessingLabel",
       -left    => 30,
       -top     => 30,
       -width   => 290,
       -height  => 20,
       -foreground    => 0,
  -visible=> 1,
      );
#----------------------------------------
&StartThreads;
$MW->Show();
Win32::GUI::Dialog;
#----------------------------------------
sub MainWindow_Terminate {
     return -1;
}
#==========================================================
sub StartThreads{
my ($x, @x, @url);

 $x = 0;
 undef @x;

 @url = ('http://search.cpan.org/', 'http://yahoo.com/', 'http://mewsoft.com/', 
'http://ayna.com/', 'http://arabikx.com/',
     'http://maktoob.com/', 'http://masrawy.com/', 'http://ajeeb.com/', 
'http://egypt.com/', 'http://search.com/');

 undef %Thread;
 undef %Done;
 undef %Result;

 for $x(0..9) {
   $y[0] = $x;
   $y[1] = $url[$x];
   $Done{$x} = 2;
   $Thread{$x} = threads->new(\&get_url, @y);
   $Thread{$x}->detach();
   $PrintMsg->Text("Created thread $x...");
 }

 #$Thread{0}->join;
 #sleep 1 until threads->tojoin;
 #while (! threads->tojoin) {print ".";sleep 1;} # This created the error  The 
memory can not be "read".
 #$_->join foreach threads->tojoin; # join all joinable threads

 while (1) {
   while (my($k, $v) = each %Done) {
     if ($v==1) {
      $PrintMsg->Text("Finished Thread $k...");
      delete $Done{$k};
     }
   }
   my $k = keys %Done;

   if (!$k) {last;}
   Win32::GUI::DoEvents();
 };

 $PrintMsg->Text("Finished ALl Threads...");
 return 1;
}
#==========================================================
sub get_url{
my ($id, $url) = @_;
my ($text);

my $ua = LWP::UserAgent->new;
my $response = $ua->get($url);

if ($response->is_success) {
     $text = $response->content;  # or whatever
  #print STDERR "Success URL: $url \n";
 }
 else {
  #print STDERR "Error URL: $url \n";
     $text = $response->status_line;
 }
 #return $text;
 $Result{$id} = $text;
 $Done{$id} = 1;
 #return "$id\n";
}
#==========================================================
#Code End


regards
Ramy

  ----- Original Message ----- 
  From: Steve Pick 
  To: [EMAIL PROTECTED] ; perl-win32-gui-users@lists.sourceforge.net 
  Sent: Sunday, January 25, 2004 3:45 AM
  Subject: Re: [perl-win32-gui-users] Win32::FileOp Erro with Win32::GUI


  Hi again,

  Maybe if you send me the source of an example that causes the error I could 
look into a fix for you, but I'm not promising anything. You'll really need to 
talk to Aldo Calpini about this. He wrote Win32::GUI and Win32::API, and his 
website is at http://dada.perl.it/

  Although he assumedly reads this list every now and again to see how people 
are abusing his babies, he hasn't posted in a very long time.

  Steve
    ----- Original Message ----- 
    From: [EMAIL PROTECTED] 
    To: Steve Pick ; perl-win32-gui-users@lists.sourceforge.net 
    Sent: Sunday, January 25, 2004 1:13 AM
    Subject: Re: [perl-win32-gui-users] Win32::FileOp Erro with Win32::GUI


    Dear Steve,

    Thanks first for your prompt reply.

    After some investigation of removing the modules from the script, 
    I found out that the main source of the error come from Win32::API module

    Since the Win32::FileOp Which uses the Win32::API therefore it generates 
the error

    That means a big loose for me and everyone that can not use Win32::API 
module
    and all modules based on using it to load and interface to windows with 
threads
    as it makes life easier with loading dll's.

    I am not sure if WIn32::API is actively updated or not as this may be a 
little bug in it

    Regards
    Ramy
      ----- Original Message ----- 
      From: Steve Pick 
      To: [EMAIL PROTECTED] ; perl-win32-gui-users@lists.sourceforge.net 
      Sent: Sunday, January 25, 2004 3:03 AM
      Subject: Re: [perl-win32-gui-users] Win32::FileOp Erro with Win32::GUI


      Hi Ramy,

      Could you verify that Win32::GUI is causing this by testing without GUI 
code running. Create an application that uses threads and Win32::FileOp without 
Win32::GUI loaded and see if the problem still occurs. If so, it's out of our 
hands and is a fault in Win32::FileOp. A lot of modules are not 
threads-compatible, and it's probable that Win32::FileOp is one of them.

      If it only happens with Win32::GUI loaded, please let us know and we'll 
undoubtable jump at the chance to look into it, such a powerhouse of activity 
that we are.

      Thanks,

      Steve
        ----- Original Message ----- 
        From: [EMAIL PROTECTED] 
        To: perl-win32-gui-users@lists.sourceforge.net 
        Sent: Saturday, January 24, 2004 10:24 PM
        Subject: [perl-win32-gui-users] Win32::FileOp Erro with Win32::GUI


        Hi All,

        I noticed that when I use the module Win32::FileOp
        in a GUI application (may be also not gui) in a Threads,
        When the threads starts, the script shows error
        that says :

        The instruction at "0x28053f9a" referenced memory at "0x000010c0". The 
memory ould not be "read".
        Click on OK to terminate the program
        Click on CANCEL to debug the program

        and sometimes it is The memory ould not be "Written" instead of "read".

        I actually found that if I use the module "Win32::API" it will generate
        this error and of course Win32::FileOp use internally this module.

        The threads works fine if I remove the "use Win32::FileOp;" line but
        I need to use it for the File Open and Save Dialogs.

        Any solutions or suggestions?

        Thank you in advance for help

        Ramy

Attachment: threads-test.cgi
Description: Binary data

Reply via email to