RadialControllerIndependentInputSource 类

定义

使应用能够处理后台线程上的径向控制器输入。

public ref class RadialControllerIndependentInputSource sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 262144)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class RadialControllerIndependentInputSource final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 262144)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class RadialControllerIndependentInputSource
Public NotInheritable Class RadialControllerIndependentInputSource
继承
Object Platform::Object IInspectable RadialControllerIndependentInputSource
属性

Windows 要求

设备系列
Windows 10 Creators Update (在 10.0.15063.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v4.0 中引入)

示例

在这里,我们在专用后台线程上创建 DispatcherQueue ,然后初始化在后台线程上创建的 RadialControllerInpdependentInputSource 对象。

public void CreateCoreIndependentInputSourceSample() 
{ 
    // Create a new thread, initialize DispatcherQueueController, 
    // and run a DispatcherQueue event loop on it. 
    _queueController =  
        DispatcherQueueController.CreateOnDedicatedThread(); 
    _queue = _queueController.DispatcherQueue;  

    // This is the first TryEnqueue() after creating the DispatcherQueue 
    // callback is guaranteed to be invoked first despite priority on the 
    // newly created thread. 
    bool isQueued = _queue.TryEnqueue( () => 
        {
            // The RadialControllerIndependentInputSource will raise events 
            // on the thread that created it.  
            radialInput = 
                RadialControllerIndependentInputSource.CreateForView(view); 
            radialInput.Controller.ButtonClicked += OnButtonClicked; 
            radialInput.Controller.ButtonHeld += OnButtonHeld; 
            radialInput.Controller.ButtonPressed += OnButtonPressed;  

            // Add RadialControllerMenuItems for this controller. 
            AddMenuItems(radialInput.Controller) 
        });         

    if (!isQueued) 
    { 
        // throw exception as this callback is enqueued. 
    } 

    // Enqueuing future tasks to this thread can be done using the DispatcherQueue 
    // property in RadialControllerIndependentInputSource.
    bool isTaskQueued = radialInput.DispatcherQueue.TryEnqueue( () => 
        { 
            // TODO. 
        }); 
}  

private DispatcherQueueController _queueController; 
private DispatcherQueue _queue; 
private RadialControllerIndependentInputSource radialInput; 

注解

调用 DispatcherQueueController.CreateOnDedicatedThread ,在实例化 RadialControllerIndependentInputSource 的后台线程上创建 DispatcherQueue 。 使用 RadialControllerIndependentInputSource.DispatcherQueue 属性访问此 DispatcherQueue

版本历史记录

Windows 版本 SDK 版本 增值
1803 17134 DispatcherQueue

属性

Controller

获取对滚轮输入设备或附件(如 Surface Dial)的引用。

Dispatcher

获取与当前视图关联的事件消息调度程序。

DispatcherQueue

获取与此 RadialControllerIndependentInputSource 关联的 DispatcherQueue

方法

CreateForView(CoreApplicationView)

获取正在运行的应用的当前 CoreWindowRadialControllerIndependentInputSource 实例。

适用于