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.

Noah 

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 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.

Michael
http://www.manning.com/foord

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.
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
>   
>
------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   

_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to