Share via


SwapChainPanel.CreateCoreIndependentInputSource(CoreInputDeviceTypes) 方法

定義

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

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

參數

deviceTypes
CoreInputDeviceTypes

列舉的合併值。

傳回

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

備註

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

使用 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

適用於

另請參閱