UWP 应用服务中的多个部分结果 [英] Multiple partial results in a UWP app service

查看:20
本文介绍了UWP 应用服务中的多个部分结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 UWP 应用服务为其他应用提供一些非 UI 处理服务包括宿主应用.为了响应,我想逐步返回结果.考虑 grep-ping 包含特定字符串的文件的文件夹:最好报告我们找到的文件,而不是最后报告所有内容.

I am trying to use an UWP app service to provide some non-UI processing service to other app including the host app. For responsiveness, I want to return the result progressively. Think about grep-ping a folder for files containing a certain string: It would be better to report the files as we found it instead of reporting everything at the end.

所以我的问题是:目前的 UWP 技术可以实现这种场景吗?(我认为通过使用多应用实例方法进行轮询可能是可能的.我想知道应用服务是否有更简单的方法.)

So my question is: Can this scenario be achieved with the current UWP technology? (I think it is probably possible via polling using the multiple app instances approach. I want to know if there's an easier method with app service.)

推荐答案

AppServiceConnection 是一个双向通信管道,因此您可以使用它来将进度更新从服务传送到客户端.不需要投票.客户端连接后,只需在您的服务实现中保留对 AppServiceConnection 实例的引用,然后调用 SendMessageAsync 随时向客户端发送进度更新.

The AppServiceConnection is a bi-directional communication pipe, so you can use it to communicate progress updates from the service to the client. No need for polling. Just retain a reference to the AppServiceConnection instance in your service implementation once the client has connected and then call SendMessageAsync to send progress updates to client whenever you want.

这篇关于UWP 应用服务中的多个部分结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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