From: John Baylor [mailto:john.baylor / gmail.com]
Sent: Friday, June 30, 2006 7:19 AM
> > static VALUE run(VALUE _self)
> > {
> >         MSG msg;
> >         while (::GetMessage(&msg, NULL, 0, 0))
> >         {
> >                 ::TranslateMessage(&msg);
> >                 ::DispatchMessage(&msg);
> >         }
> >
> >         return _self;
> > }
> >
> > I'm very surprised that Thread.new don't returns ("here" will be never
> > printed).
> Put some printfs in the C code - I think you'll find it never gets out of
> GetMessage.  If your thread has no windows it may have no events... or it
> it
> returns a negative value you'll stay in the loop as long as it gets
> errors.

I've already found the solution. In fact, there were 2 errors:
1. I had to use PeekMessage instead of GetMessage
2. I had to do rb_thread_schedule() to let Ruby's scheduler to switch
threads.

V.