不能使用create_async()与WRL WinRT组件 [英] Can't use create_async() with WRL WinRT component

查看:199
本文介绍了不能使用create_async()与WRL WinRT组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用WRL编写一个具有async支持的WinRT组件,但我发现 create_async()是未定义的,即使我包括 ppltask.h 使用命名空间并发
如何使用WRL模式创建后台任务?

I want to write a WinRT component with async support using WRL, but I found create_async() is undefined even I included the ppltask.h and using namespace concurrency How to create a background task with WRL pattern?

我的功能如下:

HRESULT GetStreamAsync([out, retval] IAsyncOperation<IRRandomAccessStream*>** operation);

我也尝试使用 IThreadPoolStatics-> RunAsync c $ c>,但似乎它只能在 IAsyncAction 的情况下使用,并且没有返回值。有人可以帮助吗?

I also try to use IThreadPoolStatics->RunAsync(), but seems it only can be used in case of IAsyncAction and without return value. Does anyone can help?

推荐答案

concurrency :: create_async 仅在C ++ / CX中可用(这可能未在文档中明确说明,但所有可能的返回类型都是帽子类型,表明它只能在C ++ / CX中使用)。

concurrency::create_async is only usable in C++/CX (this may not be expressly stated in the documentation, but all of the possible return types are hat types, indicating it is only usable in C++/CX).

WRL包括 Microsoft :: WRL :: AsyncBase 基类模板,您可以从中导出以使用C ++和WRL实现异步操作。

WRL includes the Microsoft::WRL::AsyncBase base class template, which you can derive from to implement asynchronous operations using C++ and WRL.

我不知道一个规范的实现,包括 std :: future concurrency :: task ,但您可以在Boost授权的 CxxReflect库(搜索 async_operation_base task_based_async_operation )。

I don't know of a canonical implementation that wraps std::future or concurrency::task, but you can find an example of an implementation in the Boost-licensed CxxReflect library (search for async_operation_base and task_based_async_operation).

这篇关于不能使用create_async()与WRL WinRT组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆