Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (14)
As of 2015-07-28 16:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls