John Lam 1997 — 2026

Events and RubyCLR

I got events up and running last night. It was a bit harder than I anticipated, and there’s still a bit of work that needs to be done around marshaling, but this unit test now passes:

public ref class CallbackTests {
public:
  event EventHandler^ Event;

  void CallMeBack() {
    Event(nullptr, EventArgs::Empty);
  }
};

class EventTests < Test::Unit::TestCase
  def test_simple_event
    c = System::CallbackTests.new
    c.Event do |sender, args|
      assert_equal 1, 1
    end
    c.CallMeBack
  end
end