lightspeed has asked for the wisdom of the Perl Monks concerning the following question:

Has anyone else had any problems with sleep() hanging when used inside a Tk application? Most of the code uses $widget -> after() to get delays, but the code can "do" other scripts which can contain sleep(). The problem I'm seeing is that quite regularly, sleep(1) does not return. This is in 5.8.8 for win32. The win32 sleep seems to use MsgWaitForMultipleObjects with a count of 0 and a null list inside a while (1) loop. This is hence reliant on the timeout feature of the windows call (wait for nothing and time out after n ms?). When used with Tk, doing window events, like moving/resizing seems to make it hang. Anyone else seen this? Of course I could be barking up the wrong tree completely and it could be something else. This doesn't seem to happen when running the same code under Linux though. TIA, Shaun.

Replies are listed 'Best First'.
Re: Tk and sleep() on win32
by BrowserUk (Patriarch) on Nov 07, 2008 at 11:02 UTC

    Update: Ignore this. That just gets mapped to the same stupid implementation!

    Try substituting Win32::Sleep( $millis ) and see what if any difference it makes.

    I've never understood why sleep is implemented that way on win32, when there is a perfectly good sleep function offered by the OS. Maybe it is something to do with the signals emulation?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.