[IronPython] [python] IronPython and C# asynchronous events

McCalment, Noah Noah.McCalment at mts.com
Tue Oct 23 19:10:48 CEST 2007

Unless I'm missing something concerning the use of CallTarget0, this
doesn't work either.  Neither my class code nor my script code is
anything terribly complicated, so if you can point out what I'm doing
wrong in either case, I'd be more than happy to admit my mistake.


-----Original Message-----
From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
Sent: Tuesday, October 23, 2007 11:59 AM
To: Discussion of IronPython
Subject: Re: [IronPython] [python] IronPython and C# asynchronous events

Hello Noah,

We've had no problems with synchronous and asynchronous events from 
IronPython (possibly try using the CallTarget0 delegate?), which 
suggests something wrong with your code.


McCalment, Noah wrote:
> 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.
> 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
> 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
> 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
> to retrieve a MethodInfo for a stock IronPython method.  Is this
> possible, and if so, how?
> Thanks for your time,
> Noah
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Users mailing list
Users at lists.ironpython.com

More information about the Ironpython-users mailing list