You are right to use your thread that way, with Tk. Your code is kind of complex from the description, so without REAL code examples, we can only hypothesize. :-)

The key idea is the eventloop and how it allocates time to the various widgets. You might want to experiment with sprinkiling

DoOneEvent(); # and or $mw->update;
after variable updates which are needed elsewhere as signals.

Also, with threads shared variables, the main thread is NOT automagically updated with the shared variable changes. The shared variable must be actively read, for it to cross the thread boundary.

So if $STATE_of_MSGBOX_TIMER has changed in the thread, the main thread dosn't know about it, until it reads it once. If I understand your code idea, you are trying to use that in waitVariable, but it may not have been updated properly across the thread. So I don't know if a threads shared variable can be used across threads in waitVariable.

A quick hack to tell if that's the case, is to make a timer in the main thread, that automatically updates all shared vars frequently, like

$mw->repeat( 10 , { my $dummy_var = $STATE_of_MSGBOX_TIMER });
that will force the main thread to read the shared var every 10 milliseconds.

Good luck.


I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

In reply to Re^5: Perl/Tk repeat method, callback doesn't work if... by zentara
in thread Perl/Tk repeat method, callback doesn't work if... by NewMonkMark

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.