コード例 #1
0
        protected CFRunLoopSourceCustom()
            : base(IntPtr.Zero, true)
        {
            gch = GCHandle.Alloc(this);
            var ctx = new CFRunLoopSourceContext();

            ctx.Info     = GCHandle.ToIntPtr(gch);
            ctx.Schedule = Marshal.GetFunctionPointerForDelegate(ScheduleDelegate);
            ctx.Cancel   = Marshal.GetFunctionPointerForDelegate(CancelDelegate);
            ctx.Perform  = Marshal.GetFunctionPointerForDelegate(PerformDelegate);

            var ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(CFRunLoopSourceContext)));

            try {
                Marshal.StructureToPtr(ctx, ptr, false);
                handle = CFRunLoopSourceCreate(IntPtr.Zero, 0, ptr);
            } finally {
                Marshal.FreeHGlobal(ptr);
            }

            if (handle == IntPtr.Zero)
            {
                throw new NotSupportedException();
            }
        }
コード例 #2
0
ファイル: CFRunLoop.cs プロジェクト: cwensley/xamarin-macios
        protected CFRunLoopSourceCustom()
            : base(IntPtr.Zero, true)
        {
            gch = GCHandle.Alloc(this);
            var ctx = new CFRunLoopSourceContext();

            ctx.Info     = GCHandle.ToIntPtr(gch);
            ctx.Schedule = Marshal.GetFunctionPointerForDelegate(ScheduleDelegate);
            ctx.Cancel   = Marshal.GetFunctionPointerForDelegate(CancelDelegate);
            ctx.Perform  = Marshal.GetFunctionPointerForDelegate(PerformDelegate);

            var handle = CFRunLoopSourceCreate(IntPtr.Zero, 0, ref ctx);

            InitializeHandle(handle);
        }
コード例 #3
0
ファイル: CFRunLoop.cs プロジェクト: cwensley/xamarin-macios
 extern static /* CFRunLoopSourceRef */ IntPtr CFRunLoopSourceCreate(/* CFAllocatorRef */ IntPtr allocator, /* CFIndex */ nint order, /* CFRunLoopSourceContext* */ ref CFRunLoopSourceContext context);