private static bool Initialize( IntPtr sendMessageCallback, IntPtr exitCallback, bool enableDebug = false ) { if (RPCInitialized.WaitOne(0)) { return(true); //already initialized } Console.WriteLine("Ptr1: {0}", sendMessageCallback.ToString("x")); Console.WriteLine("Ptr2: {0}", exitCallback.ToString("x")); _pySendString = Marshal.GetDelegateForFunctionPointer(sendMessageCallback, typeof(PySendStringDelegate)) as PySendStringDelegate; _pyExit = Marshal.GetDelegateForFunctionPointer(exitCallback, typeof(PyExitDelegate)) as PyExitDelegate; return(CommonInit()); }
private static bool Initialize([MarshalAs(UnmanagedType.FunctionPtr)] PySendStringDelegate sendMessageCallback, bool enableDebug = false) { #if DEBUG ConsoleHelper.CreateConsole(); if (!Debugger.IsAttached && enableDebug) { Debugger.Launch(); } #endif _pySendString = sendMessageCallback; Console.WriteLine(string.Format("Function Pointer: 0x{0:X}", Marshal.GetFunctionPointerForDelegate(sendMessageCallback))); AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionTrapper; SetAssemblyResolver(); SetPythonCulture(); return(true); }
private static bool Initialize( [MarshalAs(UnmanagedType.FunctionPtr)] PySendStringDelegate sendMessageCallback, [MarshalAs(UnmanagedType.FunctionPtr)] PyExitDelegate exitCallback, bool enableDebug = false ) { #if DEBUG ConsoleHelper.CreateConsole(); if (!Debugger.IsAttached && enableDebug) { Debugger.Launch(); } #endif //Console.WriteLine(string.Format("Function Pointer: 0x{0:X}", Marshal.GetFunctionPointerForDelegate(sendMessageCallback))); //Console.WriteLine(string.Format("Function Pointer: 0x{0:X}", Marshal.GetFunctionPointerForDelegate(exitCallback))); _pySendString = sendMessageCallback; _pyExit = exitCallback; return(CommonInit()); }