Re: Deleage Methods - was Events

Jeroen Frijters <[email protected]> Wed, 21 Sep 2016 07:34:30 +0000
Newsgroups gmane.comp.java.ikvm.devel
Message-ID <[email protected]>
I think it should be:

public native IAsyncResult BeginInvoke(MessageNotifierEventArgs args, AsyncCallback callback, Object obj);
public native void EndInvoke(IAsyncResult res);

Regards,
Jeroen

> -----Original Message-----
> From: Jim [mailto:[email protected]]
> Sent: Wednesday, September 21, 2016 0:52
> To: [email protected]
> Subject: Re: [Ikvm-developers] Deleage Methods - was Events
> 
> 
> 
> For my edification, what's the method signature for BeginInvoke and
> EndInvoke in this delegate?
> 
>      public static final class MessageDelegate extends MulticastDelegate
>      {
>          public MessageDelegate(Method m) { }
>          public native void Invoke(MessageNotifierEventArgs args);
>          //public native IAsyncResult BeginInvoke(AsyncCallback
> callback, Object obj);
>          //public native void EndInvoke(IAsyncResult res);
>          public interface Method
>          {
>              void Invoke(MessageNotifierEventArgs arg);
>          }
>      }
> 
> Thanks,
> 
> Jim
> 
> On 09/17/2016 02:12 AM, Jeroen Frijters wrote:
> > Hi Jim,
> >
> > There's no support for defining events from the Java side.
> >
> > Regards,
> > Jeroen
> >
> >> -----Original Message-----
> >> From: Jim [mailto:[email protected]]
> >> Sent: Friday, September 16, 2016 23:15
> >> To: [email protected]
> >> Subject: [Ikvm-developers] Events
> >>
> >> Given this C# snippet:
> >>
> >>      class MainClass
> >>      {
> >>          public static void Main (string[] args)
> >>          {
> >>              [...]
> >>              MessageReceiveNotifier messageNotifier = [...]
> >>              messageNotifier.MessageReceived +=
> >> c_HostCommandMessageReceived;
> >>              [...]
> >>          }
> >>
> >>          static void c_HostCommandMessageReceived (object sender,
> >> MessageNotifierEventArgs e)
> >>          {
> >>              // the status will be -1 to indicate an unsolicited
> message.
> >>              Console.WriteLine ("The Host Command Message {1} was
> >> received with Status {0}.", e.Status, e.Message);
> >>              [...]
> >>          }
> >>      }
> >>
> >> I would expect that this in Java:
> >>
> >> import cli.System.EventHandler;
> >>
> >>
> >> public class MessageReceiveNotifier  {
> >>
> >>      [...]
> >>
> >>      public static void add_MessageReceived(EventHandler
> >> messageReceivedEventHandler) {
> >>      }
> >>
> >>      public static void remove_MessageReceived(EventHandler
> >> messageReceivedEventHandler) {
> >>
> >>      }
> >>
> >> }
> >>
> >> Would meet the requirements of the line:
> >>
> >>
> >>      messageNotifier.MessageReceived += c_HostCommandMessageReceived;
> >>
> >> However MonoDevelop gives me the error:
> >>
> >> Type 'MessageReceiveNotifier' does not contain a definition for
> >> 'MessageReceived' and no extension method 'MessageReceived' of type
> >> 'MessageReceiveNotifier' can be found.  Are you missing an assembly
> >> reference?
> >>
> >> The Java class are in the same assembly and there is no complaint
> >> about MessageReceiveNotifier (and the MessageNotifierEventArgs class)
> >> so I think that the assemblies are all correct.
> >>
> >> I have tried static and non-static for the add_ remove_ methods.
> >>
> >> Help and ideas would be much appreciated?
> >>
> >> Thanks,
> >>
> >> Jim
> >>
> >>
> >> --
> >> Jim Redman
> >> (505) 662 5156 x85
> >> http://www.ergotech.com
> 
> --
> Jim Redman
> (505) 662 5156 x85
> http://www.ergotech.com
> 
> 
> ------------------------------------------------------------------------
> ------
> _______________________________________________
> Ikvm-developers mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ikvm-developers

------------------------------------------------------------------------------