Jez is correct. There are definitely what *appear* to be really complex
things going on in threads, but Rob's ThreadUtils helps to make it quite
simple for most programs.

I've got my own little system I use for some programs (which I am far
from ready to release for public use as its currently a bit of a memory
hog) that has some funky cross thread data and object passing, but its
probably the kind of thing that is only needed in very specific
instances where Rob's code won't do. For example a 6 thread system that
in reality is a layered and peer system of threads each handling their
own work but sharing certain complete non-XS object data across say, 3
threads at a time. This is a rather uncommon approach to a threading
system as usually one would simply have a worker/boss or pipeline
system, which ThreadUtils works great for.

Jason P.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Jeremy White
Sent: Friday, April 07, 2006 4:53 AM
To: [EMAIL PROTECTED]; perl-win32-gui-users@lists.sourceforge.net
Subject: RE: [perl-win32-gui-users] sharing objects


>I am trying to create a program using Win32::GUI that uses more 
>threads. A few threads should connect to a server and download data 
>permanently, and other threads should updated some list views with that

>data
>
>For doing this I need to use threads::shared and share some variables 
>like $Win and other variables like $ListView, but if I try to share 
>them I get errors like:
>
>Invalid value for shared scalar at program.pl line 19.
>
>Are there any examples of using threads with objects, references that 
>could help me learn how to use threads with Win32::GUI?

The best place to start is to download the thread utils module that Roy
May has built:

http://www.robmay.me.uk/win32gui/

This makes interthread communication much more straightforward.

The best way to share Win32-GUI objects is to share the handle, not the
actual object itself, but my advice is try to only have one thread
dealing with the GUI. For example:

Say you've got five threads downloading data, and five listviews that
you want to update. Rather than have the five threads update the
listview directly, they send a message back to the parent thread (which
is dealing with the gui) with the data for the list view. Although it
sounds complicated, it's easy with Rob's code.

Cheers,

jez.




-------------------------------------------------------
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
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/

Reply via email to