in reply to Re^2: Thread implementation for Win32::GUI
in thread Thread implementation for Win32::GUI

I recommend moving the actual work to be done into its own thread, most likely by using threads and Thread::Queue for the communication. Maybe the worker thread can signal to the main/UI thread by sending a window message.

  • Comment on Re^3: Thread implementation for Win32::GUI

Replies are listed 'Best First'.
Re^4: Thread implementation for Win32::GUI
by ckant8 (Acolyte) on Mar 28, 2013 at 03:41 UTC
    Thanks for the reply. Could you post some examples...plz

      I recommend the following setup:

      use strict; use threads; use Thread::Queue; my $remote_commands= Thread::Queue->new; my $status= Thread::Queue->new; # responses sub worker { $status->enqueue('Connecting to host'); require Net::Telnet; ... connect to host while (defined(my $cmd= $remote_commands->dequeue)) { $status->enqueue("Running [$cmd]"); $telnet->print($cmd); }; }; my $worker= threads->new( \&worker ); ... sub btQuery_Click { # ... send commands to queue $remote_commands->enqueue("cd /"); $remote_commands->enqueue("echo 'Hello World'"); ... };