SwapChainPanel.CreateCoreIndependentInputSource(CoreInputDeviceTypes) Method

Definition

Creates a core input object that handles the input types as specified by the deviceTypes parameter. This core input object can process input events on a background thread.

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

Parameters

deviceTypes
CoreInputDeviceTypes

A combined value of the enumeration.

Returns

An object that represents the input subsystem for interoperation purposes and can be used for input event connection points.

Remarks

This method enables an app that includes a SwapChainPanel to handle input and rendering independent of the XAML UI thread, because you're deliberately providing the input processing logic on a background thread. You must call CreateCoreIndependentInputSource from a non-UI thread, otherwise this method will fail.

Use the CreateCoreIndependentInputSource method to create a core input object and associate it with your SwapChainPanel. Upon successful creation, user input of the specified device types that accesses SwapChainPanel contents will be redirected to the thread that CreateCoreIndependentInputSource was called from. Your app can handle this input by registering for input events and processing those events on a background thread. In order to receive input messages through the CoreIndependentInputSource object, the app code must set a swap chain on the SwapChainPanel, and render (at a Microsoft DirectX level) from this swap chain at least once. That provides the rendering that makes hit testing possible.

You typically use CoreDispatcher.ProcessEvents as part of the event handling. Get a CoreDispatcher reference from CoreIndependentInputSource.Dispatcher. For more info on how to use background threads, see ThreadPool or Threading and async programming.

You can call CreateCoreIndependentInputSource multiple times. Each time CreateCoreIndependentInputSource is called, the previous CoreIndependentInputSource object is disassociated with the SwapChainPanel. In other words, only one CoreIndependentInputSource object can get events at a time.

For example code of how to use CreateCoreIndependentInputSource, see the DrawingPanel class definition that is part of the XAML SwapChainPanel DirectX interop sample.

CreateCoreIndependentInputSource d can return null if deviceTypes was passed as CoreInputDeviceTypes.None (that's not a typical way to call CreateCoreIndependentInputSource though).

Applies to

See also