All, I've been having some trouble connecting IronPython to events in C#. The issue is illustrated in the short test class and test script attached to this email. Specifically, the problem is this: When an external event is raised to this C# class, the event handler calls a function which iterates through the list of subscribers. When these subscribers are invoked synchronously, there is no issue; everything works fine. However, if the subscribers are invoked asynchronously, IronPython methods cannot be directly added to the subscriber list. An ArgumentNullException exception is thrown inside the .Net runtime library, somewhere in the bowels of the remoting subsystem. My questions are these: 1) Is it possible to make asynchronous events "just work", i.e. allow IronPython scripts to simply call += on an event member in a C# class and have the subscriber fire whether it is synchronous or asynchronous? 2) I have found a workaround that involves using reflection to retrieve a MethodInfo object that gets passed to Delegate.CreateDelegate(). However, this requires me to dynamically compile a C# helper class to handle events, because I cannot find a way to retrieve a MethodInfo for a stock IronPython method. Is this possible, and if so, how?
Thanks for your time, Noah
TestEvents.py
Description: TestEvents.py
Class1.cs
Description: Class1.cs
_______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
