[IronPython] Ironpython delegates never get called

Curt Hagenlocher curt at hagenlocher.org
Fri Apr 30 16:32:21 CEST 2010


How is the Master object you create from Python shared back with the C#
code? (I'm assuming that the event is being triggered from C#.) How did you
check to see that the events were processed? Does the event-triggering code
swallow exceptions?
On Fri, Apr 30, 2010 at 7:00 AM, jon vs. python <jonvspython at gmail.com>wrote:

> Hi,
> I've a couple of events in a C# assembly...
>
> public class Master
> {
>         ...
>         public delegate void            ResponseData(int id, byte function,
> byte[] data);
>         public event    ResponseData    OnResponseData;
>         public delegate void            ExceptionData(int id, byte
> function, byte exception);
>         public event    ExceptionData   OnException;
>
>
> ...that I subscribe from IronPython...
>
> import clr
> clr.AddReferenceToFile('MyModule')
> clr.AddReference('System')
> clr.AddReference('System.Net')
> ...
> from MyModule import Master
> from System import Array
> from System import Byte
>
> def response(i, f, data):
>     print "Protocol response received"
>
> def exception(i, f, e):
>     print "Protocol exception received"
>
> class myMaster(object):
>     def __init__(self, ip, port):
>         self.mst = Master()
>         self.mst.OnResponseData += response
>         self.mst.OnException += exception
>         ...
>
> ...but never get called back. I've already check that the events get
> processed. Function signatures seem to be ok too. Am I missing something?
> How can I trace what's going on?
> Thanks, Jon.
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100430/a59701a6/attachment.html>


More information about the Ironpython-users mailing list