[UWP] [C ++] [StreamSocket]读/写回调 [英] [UWP][C++][StreamSocket] read/write callback

查看:78
本文介绍了[UWP] [C ++] [StreamSocket]读/写回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我正在使用DataReader / DataWriter来读取/写入蓝牙数据。我很难解决异步问题,即我使用 

I am using DataReader/DataWriter to read/write data from Bluetooth. I struggle a async issue, that is I use 

create_task(m_writer-> StoreAsync())。然后([this](task< unsigned int> writeTask){... }

create_task(m_writer->StoreAsync()).then([this](task<unsigned int> writeTask) { ... }

写出数据。但是,我不知道如何在"then"内部建立一个回调函数。我需要等待写入结果然后再做一步。

to write data out. However, I don't have an idea on how to make a callback function inside "then". I need to wait for the write result before doing next step.

有人可以为我提供一些回调示例吗?

Does anyone can provide some callback example for me?

谢谢。

推荐答案

你好JackyLamJackyLam,

Hi JackyLamJackyLam,

你为什么要在里面制作一个回调函数呢? ;?在c ++中,我们应该能够使用"then"来等待异步方法。 

Why do you want to make a callback function inside "then"? In c++ we should be able to use "then" to wait the async method. 

当我们将CreatAsync()与creat_task()和.then()一起使用时,它将等待StoreAsync()完成。所以我们不需要担心这个。

When we use StoreAsync() with creat_task() and .then(), it will wait for the StoreAsync() to finish. So we do not need to worry about this.

最诚挚的问候,

Jayden Gu

Jayden Gu


这篇关于[UWP] [C ++] [StreamSocket]读/写回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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