winrt.windows.system.interop module
APIs for desktop interop with the Windows.System namespace.
- create_dispatcher_queue_controller(thread_type=DispatcherQueueThreadType.CURRENT, apartment_type=DispatcherQueueThreadApartmentType.NONE)
Creates a DispatcherQueueController.
Use the created DispatcherQueueController to create and manage the lifetime of a DispatcherQueue to run queued tasks in priority order on the dispatcher queue’s thread.
If thread_type is
DispatcherQueueThreadType.DEDICATED, then this function creates a thread, initializes it with the specified COM apartment, and associates a DispatcherQueue with that thread. The dispatcher queue event loop runs on the new dedicated thread until the dispatcher queue is explicitly shut down. To avoid thread and memory leaks, callDispatcherQueueController.shutdown_queue_asyncwhen you are finished with the dispatcher queue.If thread_type is
DispatcherQueueThreadType.CURRENT, then aDispatcherQueueis created and associated with the current thread. An error results if there is already aDispatcherQueueassociated with the current thread. The current thread must pump messages to allow the dispatcher queue to dispatch tasks. Before the current thread exits, it must callDispatcherQueueController.shutdown_queue_async, and continue pumping messages until theIAsyncActioncompletes.This call does not return until the
DispatcherQueueControllerand new thread (if any) are created.- Parameters:
thread_type (DispatcherQueueThreadType) – Thread affinity for a new
DispatcherQueueController.apartment_type (DispatcherQueueThreadApartmentType) – Specifies whether to initialize the COM apartment on the new thread as an application single-threaded apartment (ASTA) or a single-threaded apartment (STA). This field is relevant only if thread_type is
DispatcherQueueThreadType.DEDICATED. UseDispatcherQueueThreadApartmentType.NONEwhen thread_type isDispatcherQueueThreadType.CURRENT.
- Returns:
The created dispatcher queue controller.
- Return type:
winrt.windows.ui.composition.DispatcherQueueController- Raises:
OSErroron failure
Added in version 2.2.
- class DispatcherQueueThreadApartmentType
Defines constants that specify options around type of COM apartment for a new
DispatcherQueueController.- NONE
No COM threading apartment type specified.
- ASTA
Specifies an application single-threaded apartment (ASTA) COM threading apartment.
- STA
Specifies a single-threaded apartment (STA) COM threading apartment.
Added in version 2.2.
- class DispatcherQueueThreadType
Added in version 2.2.