From: Matthijs Langenberg Date: 2008-05-28T04:44:37+09:00 Subject: Writing event hooks called from C extensions Just for educational purposes, I'm trying to write a Ruby-C extension that allows me to hook into Carbon's event handler. So I can handle mouse clicks in Ruby. Mouse clicks (like all events) happen asynchronously, meaning that something needs to be running inside a seperate thread, but I find it hard to grasp how this all works out. I've already figured out the following code: http://pastie.org/204180. This allows me to include the 'MouseEvents' module somewhere and call 'hook'. This works, and prints 'click' to my console, but it blocks ruby. Would it be possible to start a seperate Thread from inside the C extension, which calls into ruby (or executes a block) asynchronously? - Matt