Example #1
0
        public static void LightsUpload_BeginUpload(int pad, LightsUploadCallback callback)
        {
            if (!DLLAvailable())
            {
                return;
            }

            GCHandle handle = new GCHandle();
            InternalLightsUploadCallback wrapper = delegate(int progress, IntPtr user)
            {
                try {
                    callback(progress);
                } finally {
                    // When progress = 100, this is the final call and we can release this
                    // object to GC.
                    if (progress == 100)
                    {
                        handle.Free();
                    }
                }
            };

            // Pin the callback until we get the last call.
            handle = GCHandle.Alloc(wrapper);

            SMX_LightsUpload_BeginUpload(pad, wrapper, IntPtr.Zero);
        }
Example #2
0
 private static extern void SMX_LightsUpload_BeginUpload(int pad,
                                                         [MarshalAs(UnmanagedType.FunctionPtr)] InternalLightsUploadCallback callback,
                                                         IntPtr user);