Windows Dev Center

SwapChainPanel.CreateCoreIndependentInputSource method

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 CoreIndependentInputSource CreateCoreIndependentInputSource(
  CoreInputDeviceTypes deviceTypes



Type: CoreInputDeviceTypes

A combined value of the enumeration.

Return value

Type: CoreIndependentInputSource

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


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.

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

Requirements (Windows 10 device family)

Device family


API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0


Windows::UI::Xaml::Controls [C++]



Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8.1

Minimum supported server

Windows Server 2012 R2

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]


Windows::UI::Xaml::Controls [C++]



See also

Threading and async programming
DirectX and XAML interop
XAML SwapChainPanel DirectX interop sample



© 2015 Microsoft