Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://630447]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2018-01-23 02:30 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (238 votes). Check out past polls.