.Net Events in IR

Hi there,

I know that I can register and handle .Net events in IronRuby in the
following way:
klass.some_event { |sender, args| puts “Hello!” }

Is this the only way of doing so or are there more ways?

Thanks!
Shay.

Shay F.
http://www.ironshay.com
Follow me: http://twitter.com/ironshay

Shay F. wrote:

Hi there,

I know that I can register and handle .Net events in IronRuby in the
following way:
klass.some_event { |sender, args| puts “Hello!” }

Is this the only way of doing so or are there more ways?

Thanks!
Shay.

Shay F.
http://www.ironshay.com
Follow me: http://twitter.com/ironshay

What are you looking to do currently, is there something specific you
want to accomplish?

You are sending a block, so this could be multi-line with do/end . Also,
(depending on the context of your program), you could forgo the |sender,
args| :

button.click do
puts “Something…”
puts “Very interesting…”
end

I’ve attached a very simple Windows Forms app which shows this method of
hooking up an event, firing it manually through code, and then bringing
up the GUI…

I couldn’t attach the specified file, as the forum would give me an
Application Error, will try to send to Shay directly…

Please feel free to direct message me if anyone else comes across this
and wants a copy of the file.

Otherwise, I’d suggest a better resource for writing windows apps with
IronRuby is Thibaut Barrère’s “magic”: