I'm writing an application using Perl and Gtk2-Perl that keeps track of elapsed time. It needs to perform a certain function when a count down timer expires. It would be nice if the timer generated a signal when it expired.
I see that GLib provides a GTimer 开发者_运维问答structure for this purpose, but I can't find any documentation about how to access this through Gtk2-Perl, or if this is even advisable, because maybe there's a better solution that's native to Perl.
I think you're looking for Glib::Timeout->add
or Glib::Timeout->add_seconds
.
Note that add_seconds
does more than just multiply the interval by 1000.
GLib's GTimer just keeps track of elapsed time; it doesn't emit signals. The Perlish equivalent of a GTimer would be Time::HiRes.
Looks like you can make a call to the Alarm function. That should do the trick
精彩评论