[Mono-bugs] [Bug 27980][Wis] Changed - Passing a delegate with PInvoke

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
23 Jul 2002 17:52:43 -0000


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by manyoso@yahoo.com.

http://bugzilla.ximian.com/show_bug.cgi?id=27980

--- shadow/27980	Fri Jul 19 04:18:48 2002
+++ shadow/27980.tmp.3113	Tue Jul 23 13:52:43 2002
@@ -1,13 +1,13 @@
 Bug#: 27980
 Product: Mono/Runtime
 Version: unspecified
 OS: other
 OS Details: 
 Status: NEEDINFO   
-Resolution: FIXED
+Resolution: 
 Severity: Unknown
 Priority: Wishlist
 Component: misc
 AssignedTo: mono-bugs@ximian.com                            
 ReportedBy: manyoso@yahoo.com               
 QAContact: mono-bugs@ximian.com
@@ -32,6 +32,52 @@
 ------- Additional Comments From dietmar@ximian.com  2002-07-19 04:15 -------
 AFAIK this bug is already fixed.
 
 ------- Additional Comments From dietmar@ximian.com  2002-07-19 04:18 -------
 I assume I have missunderstood the bug - a testcase would be really
 helpful
+
+------- Additional Comments From manyoso@yahoo.com  2002-07-23 13:52 -------
+Here i a test case adapted from delegate4.cs:
+
+using System;
+using System.Threading;
+using System.Runtime.InteropServices;
+using System.Runtime.Remoting.Messaging;
+
+class Test {
+	public delegate int SimpleDelegate (int a, int b);
+
+	[DllImport ("libtest.so", EntryPoint="mono_invoke_delegate")]
+	static extern int mono_invoke_delegate (SimpleDelegate d);
+
+	public static int CallBack (int a, int b) {
+		Console.WriteLine ("CallBack: " + a +  " + " + b);
+		return a + b;
+	}
+	
+	public static int BackCall (int a, int b) {
+		Console.WriteLine ("BackCall: " + a +  " + " + b);
+		return a + b;
+	}
+
+	static void Main () {
+		SimpleDelegate d = new SimpleDelegate (CallBack);
+		SimpleDelegate d1 = new SimpleDelegate (BackCall);
+		mono_invoke_delegate (d);
+		mono_invoke_delegate (d1);
+		d.DynamicInvoke (new Object[] {2,3});
+		d1.DynamicInvoke (new Object[] {2,3});
+	}
+}
+
+the output from mono is:
+
+start invoke 0x8249c08
+CallBack: 2 + 3
+end invoke
+start invoke 0x8249c08
+CallBack: 2 + 3
+end invoke
+CallBack: 2 + 3
+BackCall: 2 + 3
+