Re: Events
Jeroen Frijters <[email protected]> Sat, 17 Sep 2016 08:12:05 +0000
| Newsgroups | gmane.comp.java.ikvm.devel |
|---|---|
| Message-ID | <[email protected]> |
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 ------------------------------------------------------------------------------