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.