InputObject Class
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.
Base class for all input objects.
[WebHostHidden]
public ref class InputObject
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Foundation.WindowsAppSDKContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[WebHostHidden]
class InputObject
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.WindowsAppSDKContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public class InputObject
Public Class InputObject
- Inheritance
- Derived
- Attributes
Remarks
All input APIs in the Windows App SDK derive from the common InputObject base class.
InputObject threading model
An InputObject can only be accessed from the thread where it was created. Any property access or function call on a different thread will return RPC_E_WRONG_THREAD (or the equivalent projected error type). The only exception to this is when accessing the InputObject DispatcherQueue property. The DispatcherQueue lets you check if the current thread has access and, if not, to queue work to the affined thread.
All event callbacks are raised on the DispatcherQueue thread associated with the InputObject.
The following example shows how to determine if the InputObject belongs to the current thread.
bool OnThread(Microsoft.UI.Input.InputObject inputObject)
{
return inputObject.DispatcherQueue.HasThreadAccess();
}
Behavior when disposed
When an InputObject is disposed, all associated event handlers are unregistered automatically. Subsequent calls to unregister an event handler will succeed but are not required.
All subsequent function or property calls, including the DispatcherQueue property, will return RO_E_CLOSED (or the equivalent projected error).
Note
The InputObject memory remains valid until all references have been released, but all resources are released when disposed.
Properties
DispatcherQueue |
Gets the DispatcherQueue for the InputObject. |