title: Perl Update UI on Long Thread
body: <p>I have a Perl script running on version 5.10 build 1004 of ActiveStates Active Perl on windows xp which creates a UI and then runs a long process after a button press.  During this process I would like to update the UI (a list box) with status on what is going on during the execution of this thread.  Here is a stripped down version of the code.</p>
  
  <pre><code>#!/usr/local/bin/perl
  
  use warnings;
  use strict;
  use Tkx;
  use threads;
  use threads::shared;
  
  my $outputText = " {a} {b}";
  
  my $mw = Tkx::widget-&gt;new(".");
  $mw-&gt;g_wm_title("MD5 Checker");
  $mw-&gt;g_wm_minsize(300,200);
  my $content = $mw-&gt;new_ttk__frame(-padding =&gt; "12 12 12 12");
  my $btnCompare = $content-&gt;new_ttk__button(-text =&gt; "Compare", -command =&gt; sub{startWork()});
  my $lstbxOutput = $content-&gt;new_tk__listbox(-listvariable =&gt; \$outputText, -height =&gt; 5);
  my $scollListBox = $content-&gt;new_ttk__scrollbar(-orient =&gt; 'vertical', -command =&gt; [$lstbxOutput, 'yview']);
  $lstbxOutput-&gt;configure(-yscrollcommand =&gt; [$scollListBox, 'set']);
  
  sub startWork()
  {
      print "Starting thread \n";
      my $t = threads-&gt;create(\&amp;doWork, 1);
      sleep (5);
      print $outputText . "\n";
  }
  
  sub doWork()
  {
      for (my $a = 0; $a&lt;10; $a++)
      {
          $outputText .= " {$a}";
          print "Counting $a\n";
          sleep(2);
      }
      print "End thread\n";
  }
  </code></pre>
  
  <p>Currently the print commands are for my debugging so I know what the main and child threads are doing.  From what I have read about threading I need the <code>use threads::shared;</code> to allow threads to share variables.  At the moment my list box does not update at all during the child threads execution nor when the thread has ended.  Without the threading, the list box would update after the main thread was done with the loop.  What am I missing to get the UI to update during the threads execution?</p>
  
  <p>Thanks</p>
  
  <p>Wesley</p>