home contents changes options help

There seems to be a bug in IronPython 1.1 that prevents re-adding event handlers for an event type, after all event handlers have been removed from it by iterating thru them using GetInvocationList?(). In the same situation, adding event handlers from c# continues to work. Interestingly, in this test case it does work for me in 2.0 alpha5 - in the actual production code there was no difference. Adding c#-written methods as event handlers from ipy does not seem to work in 2.0 alpha 5 though, that works in 1.1.

This is a test case - take either the dll or compile one from the cs, put the py file in the same directory, and execute the py file with ironpy. What happens to me is shown at the bottom of this page in an example run:

ResetableEventcontainer.cs

ResetableEventcontainer.dll

test_resetableeventcontainer.py

\IronPython-1.1-Bin\IronPython-1.1\ipy.exe test_resetableeventcontainer.py

we now have 1 event handers registered. I am the built-in handler i got an event, i am happy. another one got an event too, is happy as well. yet another eventhandler, this must be enough. Removed event handler: ResetableEventcontainer.ResetableEventcontainer+MyEventCa llback removed 1 event handlers we now have 0 event handers registered. after removal, nothing should happen here: now we re-add a handler, it should work again: we now have 0 event handers registered. testing adding on csharp-side, instead: we now have 1 event handers registered. I am the built-in handler

This happens with 2.0 alpha5, because c# methods do not show as py callables, or something, eh?

IronPython-2.0A5-Bin\IronPython-2.0A5\ipy.exe test_resetableeventcontainer.py
Traceback (most recent call last):
  File test_resetableeventcontainer.py, line 22, in Initialize
  File , line 0, in _stub_##20
  File , line 0, in _stub_##21
TypeError: Object is not callable.

That line 22 is:

re.OnMyEvent += re.BuiltinHandler

Commenting out those parts, this test case seems to work otherwise perfectly in 2.0 alpha 5, also the eventhandler counts are correct:

modified version where adding BuiltinHandler? from py is commented out - test_resetableeventcontainer2.py

\IronPython-2.0A5-Bin\IronPython-2.0A5\ipy.exe test_resetableeventcontainer2.py
we now have 3 event handers registered.
i got an event, i am happy.
another one got an event too, is happy as well.
yet another eventhandler, this must be enough.
Removed event handler: ResetableEventcontainer.ResetableEventcontainer+MyEventCa
llback
Removed event handler: ResetableEventcontainer.ResetableEventcontainer+MyEventCa
llback
Removed event handler: ResetableEventcontainer.ResetableEventcontainer+MyEventCa
llback
removed 3 event handlers
we now have 0 event handers registered.
after removal, nothing should happen here:
now we re-add a handler, it should work again:
we now have 1 event handers registered.
i got an event, i am happy.
testing adding on csharp-side, instead:
we now have 2 event handers registered.
i got an event, i am happy.
I am the built-in handler

Now I guess I should test if I get the same behaviour in the actual product somehow..