# Timer event with callback

**URL:** <https://www.ruby-forum.com/t/timer-event-with-callback/237394>\
**Category:** Ruby-Gnome 2\
**Created:** [November 11, 2013, 1:24am UTC](https://www.ruby-forum.com/t/timer-event-with-callback/237394 "2013-11-11T01:24:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [November 11, 2013, 1:24am UTC](https://www.ruby-forum.com/t/timer-event-with-callback/237394/1 "2013-11-11T01:24:45Z")

</div>

Greetings,  
There is an excellent Timer in Tk, called TkRtTimer. The functionality  
is elegant: It has a callback after an elapsed amount of time.

> **[Class: TkRTTimer (Ruby 2.0.0)](https://ruby-doc.org/stdlib-2.0.0/libdoc/tk/rdoc/TkRTTimer.html)**
>
> Class : TkRTTimer - Ruby 2.0.0

When I try and include ‘tk’ in a visual ruby project I get into big  
trouble.  
Does anyone have suggestions about how to get TKRTTimer to work in  
visual ruby?  
If the task is herculean or unlikely what are the possible solutions?  
Most grateful for any help.

---

<div class="post-metadata">

**Author:** ![quickshotjoe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/cc9497/32.png) [@quickshotjoe](https://www.ruby-forum.com/u/quickshotjoe)\
**Post date:** [November 11, 2013, 2:30am UTC](https://www.ruby-forum.com/t/timer-event-with-callback/237394/2 "2013-11-11T02:30:50Z")

</div>

Experimenting with EventMachine timers. This would appear to need to run  
as a new thread in parallel with the GUI.

---

<div class="post-metadata">

**Author:** ![quickshotjoe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/cc9497/32.png) [@quickshotjoe](https://www.ruby-forum.com/u/quickshotjoe)\
**Post date:** [November 11, 2013, 4:51am UTC](https://www.ruby-forum.com/t/timer-event-with-callback/237394/3 "2013-11-11T04:51:52Z")

</div>

Sorry to bother, using Rufus-Scheduler  
Seems to work nicely.

---

<div class="post-metadata">

**Author:** ![quickshotjoe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/cc9497/32.png) [@quickshotjoe](https://www.ruby-forum.com/u/quickshotjoe)\
**Post date:** [November 11, 2013, 11:23am UTC](https://www.ruby-forum.com/t/timer-event-with-callback/237394/4 "2013-11-11T11:23:15Z")

</div>

Andru M. wrote in post #1126902:

> Greetings,  
> There is an excellent Timer in Tk, called TkRtTimer. The functionality  
> is elegant: It has a callback after an elapsed amount of time.

there is :  
GLib::Timeout.add(n) { block }

which do the job. Doc :  
[http://ruby-gnome2.sourceforge.jp/hiki.cgi?GLib::Timeout](http://ruby-gnome2.sourceforge.jp/hiki.cgi?GLib::Timeout)  
and  
[GLib – 2.0](https://developer.gnome.org/glib/2.37/glib-The-Main-Event-Loop.html#g-timeout-add)

---

<div class="post-metadata">

**Author:** ![quickshotjoe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/cc9497/32.png) [@quickshotjoe](https://www.ruby-forum.com/u/quickshotjoe)\
**Post date:** [December 12, 2013, 11:10am UTC](https://www.ruby-forum.com/t/timer-event-with-callback/237394/5 "2013-12-12T11:10:58Z")

</div>

Thanks Regis!
