Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: endless loops for server and tk

by Errto (Vicar)
on Aug 03, 2007 at 04:50 UTC ( #630447=note: print w/ replies, xml ) Need Help??

in reply to endless loops for server and tk

A couple of general points. One, yes, add a timeout to your receiving loop. In a similar example, I just used the timeout method of the IO::Socket module. That was for TCP, but I assume there's a UDP equivalent. Second, you can use the fact that you now know you'll iterate through your loop once every some interval, you can use that opportunity to call $mw->update. So the outline is:

# setup MainWindow $mw # setup socket with timeout sub myloop { while (1) { #read from socket; #if anything read, deal with it; $mw->update(); } } $mw->after(1, \&myloop); MainLoop;
This way the main loop initializes itself and renders your window, but then your code takes over and does the GUI update as often as needed.

Comment on Re: endless loops for server and tk
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://630447]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2016-02-10 00:12 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (329 votes), past polls