Share via


CreateDispatcherQueueController 函式 (dispatcherqueue.h)

建立 DispatcherQueueController。 使用建立 的 DispatcherQueueController 來建立和管理 DispatcherQueue 的存留期,以在發送器佇列的執行緒上依優先順序執行佇列工作。

語法

HRESULT CreateDispatcherQueueController(
  [in]  DispatcherQueueOptions     options,
  [out] PDISPATCHERQUEUECONTROLLER *dispatcherQueueController
);

參數

[in] options

所建立 DispatcherQueueController的執行緒親和性和 COM Apartment 類型。 如需詳細資訊,請參閱備註。

[out] dispatcherQueueController

建立的發送器佇列控制器。

重要DispatcherQueueController是 WinRT 物件。
 

傳回值

成功S_OK ;否則為失敗碼。

備註

Windows 10 1709 版中引進。

如果 options.threadType是DQTYPE_THREAD_DEDICATED,則此函式會建立執行緒、使用指定的 COM Apartment 初始化它,並將 DispatcherQueue 與該執行緒產生關聯。 發送器佇列事件迴圈會在新的專用線程上執行,直到發送器佇列明確關閉為止。 若要避免執行緒和記憶體流失,請在完成發送器佇列時呼叫 DispatcherQueueController.ShutdownQueueAsync

如果 options.threadType是DQTYPE_THREAD_CURRENT,則會建立 DispatcherQueue 並與目前線程建立關聯。 如果已經有與目前線程相關聯的 DispatcherQueue ,則會產生錯誤。 目前的執行緒必須提取訊息,才能讓發送器佇列分派工作。 在目前的執行緒結束之前,它必須呼叫 DispatcherQueueController.ShutdownQueueAsync,然後繼續幫浦訊息,直到 IAsyncAction 完成為止。

在建立任何) 之前,這個呼叫不會傳回 DispatcherQueueController 和新執行緒 (。

重要DispatcherQueueController及其相關聯的DispatcherQueue是 WinRT 物件。 如需使用詳細資料,請參閱其檔。
 

規格需求

   
目標平台 Windows
標頭 dispatcherqueue.h
程式庫 CoreMessaging.lib
Dll CoreMessaging.dll

另請參閱

DispatcherQueue

DispatcherQueueController