Share via


SwapChainPanel.CreateCoreIndependentInputSource 方法

定義

多載

CreateCoreIndependentInputSource(InputPointerSourceDeviceKinds)

建立核心輸入物件,以處理 deviceKinds 參數所指定的輸入類型。 這個核心輸入物件可以處理背景線程上的輸入事件。

CreateCoreIndependentInputSource(CoreInputDeviceTypes)

建立核心輸入物件,以處理 deviceTypes 參數所指定的輸入類型。 這個核心輸入物件可以處理背景線程上的輸入事件。

CreateCoreIndependentInputSource(InputPointerSourceDeviceKinds)

建立核心輸入物件,以處理 deviceKinds 參數所指定的輸入類型。 這個核心輸入物件可以處理背景線程上的輸入事件。

public:
 virtual InputPointerSource ^ CreateCoreIndependentInputSource(InputPointerSourceDeviceKinds deviceKinds) = CreateCoreIndependentInputSource;
InputPointerSource CreateCoreIndependentInputSource(InputPointerSourceDeviceKinds const& deviceKinds);
public InputPointerSource CreateCoreIndependentInputSource(InputPointerSourceDeviceKinds deviceKinds);
function createCoreIndependentInputSource(deviceKinds)
Public Function CreateCoreIndependentInputSource (deviceKinds As InputPointerSourceDeviceKinds) As InputPointerSource

參數

deviceKinds
InputPointerSourceDeviceKinds

列舉的合併值。

傳回

物件,表示用於 Interop 用途的輸入子系統,可用於輸入事件連接點。

備註

此方法可讓包含 SwapChainPanel 的應用程式處理與 XAML UI 線程無關的輸入和轉譯,因為您刻意在背景線程上提供輸入處理邏輯。 您必須從非 UI 線程呼叫 CreateCoreIndependentInputSource,否則此方法將會失敗。

使用這個方法來建立核心輸入物件,並將它與您的 SwapChainPanel 產生關聯。 成功建立時,會重新導向存取 SwapChainPanel 內容之指定裝置類型的使用者輸入,並重新導向至從中呼叫 CreateCoreIndependentInputSource 的線程。 您的應用程式可以註冊輸入事件,並在背景線程上處理這些事件,來處理此輸入。 若要透過 CoreIndependentInputSource 物件接收輸入訊息,應用程式程式代碼必須在 SwapChainPanel 上設定交換鏈結,並在 Microsoft DirectX 層級 (轉譯) 至少一次。 這會提供可進行點擊測試的轉譯。

您通常會使用 CoreDispatcher.ProcessEvents 作為事件處理的一部分。 從 CoreIndependentInputSource.Dispatcher 取得 CoreDispatcher 參考。 如需如何使用背景線程的詳細資訊,請參閱 ThreadPoolThreading 和異步程序設計

您可以多次呼叫這個方法。 每次呼叫 CreateCoreIndependentInputSource 時,先前的 CoreIndependentInputSource 物件會與 SwapChainPanel 解除關聯。 換句話說,一次只能取得一個 CoreIndependentInputSource 物件。

如需如何使用 CreateCoreIndependentInputSource 的範例程式代碼,請參閱 DrawingPanelXAML SwapChainPanel DirectX Interop 範例的類別定義。

如果 deviceKinds 傳遞為 InputPointerSourceDeviceKinds.None (,則 CreateCoreIndependentInputSource 可以傳回 null,這不是呼叫 CreateCoreIndependentInputSource 但) 的一般方式。

另請參閱

適用於

CreateCoreIndependentInputSource(CoreInputDeviceTypes)

建立核心輸入物件,以處理 deviceTypes 參數所指定的輸入類型。 這個核心輸入物件可以處理背景線程上的輸入事件。

public:
 virtual ExpIndependentPointerInputObserver ^ CreateCoreIndependentInputSource(CoreInputDeviceTypes deviceTypes) = CreateCoreIndependentInputSource;
ExpIndependentPointerInputObserver CreateCoreIndependentInputSource(CoreInputDeviceTypes const& deviceTypes);
public ExpIndependentPointerInputObserver CreateCoreIndependentInputSource(CoreInputDeviceTypes deviceTypes);
function createCoreIndependentInputSource(deviceTypes)
Public Function CreateCoreIndependentInputSource (deviceTypes As CoreInputDeviceTypes) As ExpIndependentPointerInputObserver

參數

deviceTypes
CoreInputDeviceTypes

列舉的合併值。

傳回

物件,表示用於互操作用途的輸入子系統,並可用於輸入事件連接點。

備註

此方法可讓包含 SwapChainPanel 的應用程式處理與 XAML UI 線程無關的輸入和轉譯,因為您刻意在背景線程上提供輸入處理邏輯。 您必須從非 UI 線程呼叫 CreateCoreIndependentInputSource,否則此方法將會失敗。

使用這個方法來建立核心輸入物件,並將它與您的 SwapChainPanel 產生關聯。 成功建立時,會重新導向存取 SwapChainPanel 內容之指定裝置類型的使用者輸入,並重新導向至從中呼叫 CreateCoreIndependentInputSource 的線程。 您的應用程式可以註冊輸入事件,並在背景線程上處理這些事件,來處理此輸入。 若要透過 CoreIndependentInputSource 物件接收輸入訊息,應用程式程式代碼必須在 SwapChainPanel 上設定交換鏈結,並在 Microsoft DirectX 層級 (轉譯) 至少一次。 這會提供可進行點擊測試的轉譯。

您通常會使用 CoreDispatcher.ProcessEvents 作為事件處理的一部分。 從 CoreIndependentInputSource.Dispatcher 取得 CoreDispatcher 參考。 如需如何使用背景線程的詳細資訊,請參閱 ThreadPoolThreading 和異步程序設計

您可以多次呼叫 CreateCoreIndependentInputSource。 每次呼叫 CreateCoreIndependentInputSource 時,先前的 CoreIndependentInputSource 物件會與 SwapChainPanel 解除關聯。 換句話說,一次只能取得一個 CoreIndependentInputSource 物件。

如需如何使用 CreateCoreIndependentInputSource 的範例程式代碼,請參閱 DrawingPanelXAML SwapChainPanel DirectX Interop 範例的類別定義。

如果 deviceTypes 傳遞為 CoreInputDeviceTypes.None (不是透過) 呼叫 CreateCoreIndependentInputSource 的一般方式,CreateCoreIndependentInputSource d 可能會傳回 null

另請參閱

適用於