SwapChainPanel.CreateCoreIndependentInputSource Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
CreateCoreIndependentInputSource(InputPointerSourceDeviceKinds) |
Creates a core input object that handles the input types as specified by the deviceKinds parameter. This core input object can process input events on a background thread. |
CreateCoreIndependentInputSource(CoreInputDeviceTypes) |
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. |
CreateCoreIndependentInputSource(InputPointerSourceDeviceKinds)
Creates a core input object that handles the input types as specified by the deviceKinds parameter. This core input object can process input events on a background thread.
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
Parameters
- deviceKinds
- InputPointerSourceDeviceKinds
A combined value of the enumeration.
Returns
An object that represents the input subsystem for interop purposes and which 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 this 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. This 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 this method 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 can return null if deviceKinds was passed as InputPointerSourceDeviceKinds.None (that's not a typical way to call CreateCoreIndependentInputSource though).
See also
- ThreadPool
- Threading and async programming
- DirectX and XAML interop
- XAML SwapChainPanel DirectX interop sample
- Low latency input sample
Applies to
CreateCoreIndependentInputSource(CoreInputDeviceTypes)
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 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
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 this 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).
See also
- CoreIndependentInputSource
- ThreadPool
- Threading and async programming
- DirectX and XAML interop
- XAML SwapChainPanel DirectX interop sample
- Low latency input sample (Windows 10)