On Wed, 2003-02-26 at 12:17, Soren Harward wrote:

> All this works fine, except for one little point: when the timeout
> triggers, it pretty much stops the entire program until the machine is
> contacted and the icon updated.  Then the next timeout triggers (I've
> got them staggered by a few seconds), and the program stops again.  If
> one function call doesn't respond by the time the next triggers, you get
> a long queue of backed-up function calls, which just locks up the
> program even more.

True enough.  There's no way around this using only timeouts.  Like all
event handlers, they are part of the main loop and as long as they don't
return, the gui is stopped.  You can do a 

while (gtk_events_pending())
    gtk_main_iteration();

at various parts of the callback if the call back is taking a long
time.  Of course if you're waiting for a ping, that won't do any good.


> 
> What would be the best solution to this problem?  I was thinking that I
> could make the program multithreaded, putting the ping-and-update
> function into a separate thread for each machine, and then if one
> machine didn't respond for a while the others wouldn't be affected, and
> the program as a whole would keep running.  Would this be the most
> efficient solution, or is there a better one?

Threading is the best way.  Just pay attenting to the threading section
of the gtk FAQ. 


-- 
Michael L Torrie <[EMAIL PROTECTED]>

____________________
BYU Unix Users Group 
http://uug.byu.edu/ 
___________________________________________________________________
List Info: http://phantom.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to