Exemple #1
0
        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());
        }
Exemple #2
0
        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());
        }
 public KodiBridgeInstance(IntPtr sendStringFuncPtr, IntPtr exitFuncPtr)
 {
     this.nativeBridge = new KodiBridgeABI(sendStringFuncPtr);
     this.exitCallback = Marshal.GetDelegateForFunctionPointer <PyExitDelegate>(exitFuncPtr);
 }