Example #1
0
        // Create dispatcher queue.
        private object InitializeCoreDispatcher()
        {
            var options = new DispatcherQueueOptions();

            options.apartmentType = DISPATCHERQUEUE_THREAD_APARTMENTTYPE.DQTAT_COM_STA;
            options.threadType    = DISPATCHERQUEUE_THREAD_TYPE.DQTYPE_THREAD_CURRENT;
            options.dwSize        = Marshal.SizeOf(typeof(DispatcherQueueOptions));

            CreateDispatcherQueueController(options, out object queue);
            return(queue);
        }
        private void EnsureDispatcherQueue()
        {
            if (_dispatcherQueueController == null)
            {
                DispatcherQueueOptions options = new DispatcherQueueOptions();
                options.apartmentType = DISPATCHERQUEUE_THREAD_APARTMENTTYPE.DQTAT_COM_NONE;
                options.threadType    = DISPATCHERQUEUE_THREAD_TYPE.DQTYPE_THREAD_CURRENT;
                options.dwSize        = Marshal.SizeOf(typeof(DispatcherQueueOptions));

                CreateDispatcherQueueController(options, out var queue);
                _dispatcherQueueController = Windows.System.DispatcherQueueController.FromAbi(queue);
            }
        }
Example #3
0
        private object InitializeCoreDispatcher()
        {
            DispatcherQueueOptions options = new DispatcherQueueOptions
            {
                apartmentType = DISPATCHERQUEUE_THREAD_APARTMENTTYPE.DQTAT_COM_STA,
                threadType = DISPATCHERQUEUE_THREAD_TYPE.DQTYPE_THREAD_CURRENT,
                dwSize = Marshal.SizeOf(typeof(DispatcherQueueOptions))
            };

            var hresult = CreateDispatcherQueueController(options, out object queue);
            if (hresult != 0)
            {
                Marshal.ThrowExceptionForHR(hresult);
            }

            return queue;
        }
Example #4
0
        public static DispatcherQueueController CreateDispatcherQueueControllerForCurrentThread()
        {
            var options = new DispatcherQueueOptions
            {
                dwSize        = Marshal.SizeOf <DispatcherQueueOptions>(),
                threadType    = DISPATCHERQUEUE_THREAD_TYPE.DQTYPE_THREAD_CURRENT,
                apartmentType = DISPATCHERQUEUE_THREAD_APARTMENTTYPE.DQTAT_COM_NONE
            };

            DispatcherQueueController controller = null;
            uint hr = CreateDispatcherQueueController(options, out IntPtr controllerPointer);

            if (hr == 0)
            {
                controller = Marshal.GetObjectForIUnknown(controllerPointer) as DispatcherQueueController;
                Marshal.Release(controllerPointer);
            }

            return(controller);
        }
Example #5
0
 public static extern HRESULT CreateDispatcherQueueController(DispatcherQueueOptions options, [NativeTypeName("PDISPATCHERQUEUECONTROLLER *")] void **dispatcherQueueController);
Example #6
0
 internal static extern IntPtr CreateDispatcherQueueController(DispatcherQueueOptions options,
                                                               [MarshalAs(UnmanagedType.IUnknown)]
                                                               out object dispatcherQueueController);
Example #7
0
 internal static extern IntPtr CreateDispatcherQueueController(DispatcherQueueOptions options);
Example #8
0
 static extern UInt32 CreateDispatcherQueueController(DispatcherQueueOptions options, out IntPtr dispatcherQueueController);
Example #9
0
 private static extern int CreateDispatcherQueueController([In] DispatcherQueueOptions options, [In, Out, MarshalAs(UnmanagedType.IUnknown)] ref object dispatcherQueueController);