public static int Init(IntPtr nativeHandlesPtr, int nativeHandlesLength, ICoreFunctionHandler functionHandler) { FunctionHandler = functionHandler; if (nativeHandlesPtr == IntPtr.Zero) { Console.WriteLine("Received NULL bootstrap structure"); return(1); } int expectedLength = Marshal.SizeOf(typeof(NativeHandles)); if (nativeHandlesLength < expectedLength) { Console.WriteLine($"Received bootstrap structure too small - actual={nativeHandlesLength}, expected={expectedLength}"); return(1); } if (nativeHandlesLength > expectedLength) { Console.WriteLine($"WARNING: Received bootstrap structure bigger than expected - actual={nativeHandlesLength}, expected={expectedLength}"); Console.WriteLine(" This usually means that native code version is ahead of the managed code"); } NativeFunctions = Marshal.PtrToStructure <NativeHandles>(nativeHandlesPtr); return(0); }
public static int Init(IntPtr nativeHandlesPtr, int nativeHandlesLength, ICoreFunctionHandler functionHandler, ICoreEventHandler eventHandler) { int result = Init(nativeHandlesPtr, nativeHandlesLength, functionHandler); if (result == 0) { RegisterEventHandles(eventHandler); } return(result); }