use strict; use Win32::GUI(); use WWW::Mechanize; use HTTP::Cookies; use threads; use Thread::Queue; #define some variables my @somearray = ("stuff"); my $thr; my $DataQueue = Thread::Queue->new(); #do all of the create windows/add control stuff my $main = Win32::GUI::Window->new( -name => "main", ); my $main_text_window = $main->AddTextfield( -name => "main_text", -multiline => 1, -readonly => 1, -vscroll => 1, ); $main->Show(); #call the main loop in a new thread $thr = threads->create(\&mainloop, @somearray); #wait for data, print data to GUI textbox while(Win32::GUI::DoEvents() != -1) { my $tmptxt = $DataQueue->dequeue(); $main_text_window->Append($tmptxt); } sub mainloop { while (1) { #lots of page getting and number crunching goes here $DataQueue->enqueue("some data"); } }