// 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); } }
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; }
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); }
public static extern HRESULT CreateDispatcherQueueController(DispatcherQueueOptions options, [NativeTypeName("PDISPATCHERQUEUECONTROLLER *")] void **dispatcherQueueController);
internal static extern IntPtr CreateDispatcherQueueController(DispatcherQueueOptions options, [MarshalAs(UnmanagedType.IUnknown)] out object dispatcherQueueController);
internal static extern IntPtr CreateDispatcherQueueController(DispatcherQueueOptions options);
static extern UInt32 CreateDispatcherQueueController(DispatcherQueueOptions options, out IntPtr dispatcherQueueController);
private static extern int CreateDispatcherQueueController([In] DispatcherQueueOptions options, [In, Out, MarshalAs(UnmanagedType.IUnknown)] ref object dispatcherQueueController);