Increment the $exit var inside of Win_Terminate: {$exit++; -1}
-----Original Message-----
From: Octavian Rasnita [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 22, 2006 11:32 AM
To: Plum, Jason; [email protected]
Subject: Re: [perl-win32-gui-users] threads error
Ok, I have tried using threads::shared, but with no effect.
I am not able to close it.
Here is the program:
use strict;
use threads;
use threads::shared;
use Win32::GUI;
my $exit : shared;
$SIG{INT} = $SIG{BREAK} = $SIG{HUP} = sub {$exit++};
my $thread = threads->new(\&download);
my $Win = Win32::GUI::Window->new(
-name => "Win",
-title => "test",
-size => [400, 400],
-dialogui => 1,
);
$Win->Show();
Win32::GUI::Dialog();
$thread->join();
sub Win_Terminate {-1}
sub download {
while(!$exit) {
Win32::GUI::MessageBox($Win, "test", "t", MB_OK); sleep 10; } }
Teddy
----- Original Message -----
From: "Plum, Jason" <[EMAIL PROTECTED]>
To: "Octavian Rasnita" <[EMAIL PROTECTED]>;
<[email protected]>
Sent: Wednesday, March 22, 2006 5:33 PM
Subject: RE: [perl-win32-gui-users] threads error
Ah...
Your problem is that you are using a indicator (aka semaphore) to stop
the child thread. This semaphore is NOT a shared variable as it stands,
thus causeing the problem.
Solution:
Use threads::shared;
My $exit : shared;
Try that :)
Jason P.
-ps, sry listfellows, I forgot to stick you in the original replies :x-
-----Original Message-----
From: Octavian Rasnita [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 22, 2006 10:28 AM
To: Plum, Jason
Subject: Re: [perl-win32-gui-users] threads error
Hi,
If I do that, it gives an error telling that a detached thread cannot be
joined.
If I don't use detach() at all, I cannot close the program and I need to
use the task manager for doing this.
Here is the test program I have made:
use strict;
use threads;
use Win32::GUI;
my $exit;
$SIG{INT} = $SIG{BREAK} = $SIG{HUP} = sub {$exit++};
my $thread = threads->new(\&download);
#$thread->detach();
my $Win = Win32::GUI::Window->new(
-name => "Win",
-title => "test",
-size => [400, 400],
-dialogui => 1,
);
$Win->Show();
Win32::GUI::Dialog();
$thread->join();
sub Win_Terminate {-1}
sub download {
while(!$exit) {
Win32::GUI::MessageBox($Win, "test", "t", MB_OK); sleep 10; } }
Thank you
Teddy
----- Original Message -----
From: "Plum, Jason" <[EMAIL PROTECTED]>
To: "Octavian Rasnita" <[EMAIL PROTECTED]>
Sent: Wednesday, March 22, 2006 4:38 PM
Subject: RE: [perl-win32-gui-users] threads error
Call the thread->join() after Win32::GUI::Dialog has ended. This shoud
solve all of your problems.
Jason P
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Octavian Rasnita
Sent: Wednesday, March 22, 2006 5:30 AM
To: [email protected]
Subject: [perl-win32-gui-users] threads error
Hi,
I have tried the following start of program:
use strict;
use threads;
use Win32::GUI;
use Win32::Internet;
use Compress::Zlib;
my $thread = threads->new(\&download);
###$thread->join();
$thread->detach();
my $exit;
$SIG{INT} = $SIG{BREAK} = $SIG{HUP} = sub {$exit++};
alarm(0);
my $Win = Win32::GUI::Window->new(
....
The program runs fine, the sub "download" seems to also run with no
issues in a separate thread, but when closing the program, it gives that
error that a thread was closed while 2 threads were running...
If I use $thread->join() instead of $thread->detach(), this error
doesn't appear, but the program waits for that thread, and doesn't
create the main window at all.
How can I do to let that thread running in the same time with the main
program, but not give error on program close?
Thank you.
Teddy
Teddy
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language that extends applications into web and mobile media. Attend the
live webcast and join the prime developer group breaking into this new
coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Perl-Win32-GUI-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.2.6/287 - Release Date: 3/21/2006
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the live
webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?cmd=k&kid0944&bid$1720&dat1642
_______________________________________________
Perl-Win32-GUI-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.2.6/287 - Release Date: 3/21/2006