示例#1
0
        private static void RegisterNativeEventHandles()
        {
            int    size = Marshal.SizeOf(typeof(NativeEventHandles));
            IntPtr ptr  = Marshal.AllocHGlobal(size);

            Marshal.StructureToPtr(eventHandles, ptr, false);
            NativeFunctions.RegisterHandlers(ptr, (uint)size);
            Marshal.FreeHGlobal(ptr);
        }
示例#2
0
        private static void RegisterEventHandles(ICoreEventHandler eventHandler)
        {
            eventHandles.MainLoop  = eventHandler.OnMainLoop;
            eventHandles.RunScript = eventHandler.OnRunScript;
            eventHandles.Closure   = eventHandler.OnClosure;
            eventHandles.Signal    = eventHandler.OnSignal;

            int    size = Marshal.SizeOf(typeof(NativeEventHandles));
            IntPtr ptr  = Marshal.AllocHGlobal(size);

            Marshal.StructureToPtr(eventHandles, ptr, false);
            NativeFunctions.RegisterHandlers(ptr, (uint)size);
            Marshal.FreeHGlobal(ptr);
        }