小编Gen*_*bie的帖子

在 C++/WinRT 项目中使用 CoreDispatcher::RunAsync 时出现“在定义之前不能使用返回‘auto’的函数”

在我的 C++/WinRT 项目中,我试图在 UI 线程上运行一些代码,但收到一条错误消息:

“winrt::impl::consume_Windows_UI_Core_ICoreDispatcher<winrt::Windows::UI::Core::ICoreDispatcher>::RunAsync':在定义之前不能使用返回'auto'的函数”

我正在调用这样的方法:

Dispatcher().RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, [=]()
{
     // Code to be executed.
});
Run Code Online (Sandbox Code Playgroud)

该实现来自自动生成的 winrt 文件,该文件auto作为返回类型返回。

template <typename D>
struct consume_Windows_UI_Core_ICoreDispatcher
{
    [[nodiscard]] auto HasThreadAccess() const;
    auto ProcessEvents(Windows::UI::Core::CoreProcessEventsOption const& options) const;
    auto RunAsync(Windows::UI::Core::CoreDispatcherPriority const& priority, Windows::UI::Core::DispatchedHandler const& agileCallback) const;
    auto RunIdleAsync(Windows::UI::Core::IdleDispatchedHandler const& agileCallback) const;
};
Run Code Online (Sandbox Code Playgroud)

有什么我遗漏的还是这是一个错误?

uwp c++-winrt

4
推荐指数
1
解决办法
1015
查看次数

标签 统计

c++-winrt ×1

uwp ×1