BackgroundTask和Task的用法 [英] Usage of BackgroundTask and Task
问题描述
嗨
Hi
我已经编写了一个"处理"的Windows应用程序(myAPP)。输入文件并生成输出。 处理阶段最多可能需要5分钟才能完成。
I've have written a windows store app(myAPP) that "processes" a input file and produces a output. The processing stage can take up to 5 minutes to perform.
我正在搜索一个设计模式 可以处理以下事项 功能:
I am searching a design pattern that can handle the following functionality:
- myAPP可见。在开始处理阶段和处理阶段期间,应更新进度指示器。
- myAPP可见。用户应能够"取消"处理阶段。
- 用户应该能够转移到处理阶段和处理阶段的另一个应用程序不会被中断。
- myAPP不可见。处理阶段结束后,应向用户发送一条消息并保存数据。
- myAPP可见。当用户在流程阶段恢复我的应用程序时,应更新进度指示器。
- myAPP可见,4个已发生的数据应该加载。
- myAPP is visible. Upon starting the processing stage, and during processing stage,, a progress indicator should be updated.
- myAPP is visible. User shall be able to "Cancel" the processing stage.
- User shall be able to shift to another application during processing stage and the processing stage will not be interrupted.
- myAPP is not visible. When the processing stage are finished a message shall be sent to the user and data saved.
- myAPP goes visible. When user restores my application during process stage, progress indicator should be updated.
- myAPP goes visible and 4 have occurred data should be loaded.
我认为使用BackgroundTask和Task, ,可以做到这一点,是否有一种既定的优雅方式来做到这一点?
I think that using BackgroundTask and Task,, can do the trick,, is there a established elegant way to do this?
可以 nyone 举个好例子。
Can anyone give a good example.
//关于
//regards
// lg
Lasse
推荐答案
Hi Lasse,
Hi Lasse,
您可以使用后台任务在应用暂停时提供功能或不运行。任务只能在应用程序处于活动状态时执行。根据您的要求,我认为BackgroundTask更合适。
You can use background tasks to provide functionality when your app is suspended or not running. Task can only be executed while the app is alive. For your requirement, I think BackgroundTask is much more suitable.
更多信息请阅读:
通过后台任务支持您的应用
--James
这篇关于BackgroundTask和Task的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!