Hi all,

Having a bit of an issue I'm hoping someone can help me with. I've created a script that uses Win32::GUI. The script retrieves webpages full of numbers and stuff, parses the numbers, compares them, etc. Processing can take minutes or more.

While the retrieving and processing is being done, the gui is sluggish and unresponsive. To solve this I discovered threads and implemented them, but it did not fix the problem. Everything looks correct to me, so I'm not sure what I can do to fix it. I'm using Strawberry 5.16.3, if that matters.

Here is a (heavily condensed) version of the code:

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"); } }

Also, I know about placing DoEvents() in the mainloop, but it slows down the processing quite a bit and does not help during page retrieval. I've also tried Win32::GUI::Timer (putting the dequeue and append command in the _Timer sub). It still seems to freeze when pages are being retrieved.

thanks!


In reply to Win32::GUI window freezing, even with threading. by chute

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.