【问题标题】:timeSetEvent missing with VS2017 on ARM platform [closed]ARM平台上的VS2017缺少timeSetEvent [关闭]
【发布时间】:2018-09-05 14:36:02
【问题描述】:

我正在使用 Visual Studio 2017 为 ARM 平台(Raspberry Pi 3 B + with windows iOT)进行开发。我正在寻找使用来自mmiscapi2.htimeSetEvent 函数。不幸的是,该功能在 ARM 平台上不可用。

是否有另一个标题可以替代mmiscapi2.htimeSetEvent?还是应该为 ARM 使用不同的函数 n?

我有很多困难,我不知道我是否清楚。如果没有,请提出问题。

谢谢。

【问题讨论】:

    标签: windows visual-studio windowsiot windows-iot-core-10


    【解决方案1】:

    timeSetEvent 是桌面 API,它已过时。新的应用程序应该使用 CreateTimerQueueTimer 创建一个 timer-queue timer。

    不幸的是,Windows 10 IoT Core 不支持 CreateTimerQueueTimer。 Windows 10 IoT Core only supports a subset of the Win32 and .Net API surface area available on various prior versions of Windows.

    UWP 是 Windows IoT Core 上的主要应用程序类型。在 UWP 中,您可以使用 ThreadPoolTimerDispatcherTimer 来创建周期性计时器。

    您可以参考“HelloBlinkyBackground”和“HelloBlinky”示例了解如何使用它们。

    更新:这是 UWP 中的 DispatcherTimer 示例。

    MainPage.xaml.cpp

    #include "pch.h"
    #include "MainPage.xaml.h"
    
    using namespace App5;
    
    using namespace Platform;
    using namespace Windows::Foundation;
    using namespace Windows::Foundation::Collections;
    using namespace Windows::UI::Xaml;
    using namespace Windows::UI::Xaml::Controls;
    using namespace Windows::UI::Xaml::Controls::Primitives;
    using namespace Windows::UI::Xaml::Data;
    using namespace Windows::UI::Xaml::Input;
    using namespace Windows::UI::Xaml::Media;
    using namespace Windows::UI::Xaml::Navigation;
    
    // The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
    
    MainPage::MainPage()
    {
        InitializeComponent();
    
    
        timer_ = ref new DispatcherTimer();
        TimeSpan interval;
        interval.Duration = 500 * 1000 * 10;
        timer_->Interval = interval;
        timer_->Tick += ref new EventHandler<Object ^>(this, &MainPage::OnTick);
        timer_->Start();
    
    }
    
    void MainPage::OnTick(Object ^sender, Object ^args)
    {
    
    }
    

    MainPage.xaml.h

    //
    // MainPage.xaml.h
    // Declaration of the MainPage class.
    //
    
    #pragma once
    
    #include "MainPage.g.h"
    
    namespace App5
    {
        /// <summary>
        /// An empty page that can be used on its own or navigated to within a Frame.
        /// </summary>
        public ref class MainPage sealed
        {
        public:
            MainPage();
    
        private:
            void OnTick(Platform::Object ^sender, Platform::Object ^args);
    
            Windows::UI::Xaml::DispatcherTimer ^timer_;
    
        };
    }
    

    C++ UWP项目结构:

    【讨论】:

    • 感谢您的帮助。目前,我没有成功。我使用 Visual Studio 2017,它不识别 DispatcherTimer(),它可能不在参考文献中,所以我正在看那一边。
    • @KingoftheStoneAge DispatcherTimer() 包含在 Windows::UI::Xaml 命名空间中,您需要引用它。我通过添加一个简单的示例代码来更新我的答案,您可以检查一下。
    • 事实上我正在尝试升级一个在win32上运行的旧软件。并使其在 ARM (Raspberry Pi 3 B+) 上运行。特别是,现在我正在尝试升级 .dll,并且引用不想添加
    • 因为您最初的问题是为 ARM 开发应用程序。要升级现有的 WIN32 应用程序,也许您可​​以尝试desktop bridge"Bringing your existing desktop apps to UWP"
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多