public static void RunGetFcnPtrSingleMulticastTest() { Console.WriteLine($"Running {nameof(RunGetFcnPtrSingleMulticastTest)}..."); { IntPtr fcnptr = Marshal.GetFunctionPointerForDelegate <DelegateWithLong>(s_DelWithLongBool); Assert.IsTrue(FunctionPointerNative.CheckFcnPtr(fcnptr)); } { IntPtr fcnptr = Marshal.GetFunctionPointerForDelegate <MultiDelegateWithLong>(s_MultidelWithLong); FunctionPointerNative.CheckFcnPtr(fcnptr); } }
public delegate void MultiDelegateWithLong(long l); //Multicast delegate public static void RunGetFcnPtrSingleMulticastTest() { Console.WriteLine($"Running {nameof(RunGetFcnPtrSingleMulticastTest)}..."); DelegateWithLong del = new DelegateWithLong(Method); MultiDelegateWithLong multidel = new MultiDelegateWithLong(Method2); { IntPtr fcnptr = Marshal.GetFunctionPointerForDelegate <DelegateWithLong>(del); Assert.IsTrue(FunctionPointerNative.CheckFcnPtr(fcnptr)); } { IntPtr fcnptr = Marshal.GetFunctionPointerForDelegate <MultiDelegateWithLong>(multidel); FunctionPointerNative.CheckFcnPtr(fcnptr); } bool Method(long l) { if (l != 999999999999) { return(false); } else { return(true); } } void Method2(long l) { if (l != 999999999999) { throw new Exception("Failed multicast call"); } } }