简体   繁体   English

WP7后台线程

[英]WP7 background threads

Are the threads in a WP7, exist across the app, or are they confined to a page ? WP7中的线程是存在于整个应用程序中还是被限制在页面中? Say I started download on a page, which is being handled by a background thread as usual, and its progress is being updated by a status bar. 假设我开始在一个页面上下载,该页面通常由后台线程处理,并且其进度由状态栏更新。 Now the user wishes to use other aspects of the application. 现在,用户希望使用应用程序的其他方面。 Will the background thread die if he navigates to another page, either using Application bar controls or back button, to a page within the app ? 如果后台线程使用“应用程序”栏控件或“后退”按钮导航到应用程序内的另一页,是否会死掉? If not what is a good practice regarding background thread dedicated only to downloads... like if they can exist across the app, should they be initiated when the app is initiated and made to wait until the download queue has a request queued up ? 如果不是,关于仅用于下载的后台线程的良好做法是什么……就像它们可以存在于整个应用程序中一样,是否应在启动应用程序时启动它们并使其等待下载队列中的请求排队?

Thnx n
-Egon -伊贡

If you have a thread that is purely dedicated to downloading an external resource I'd launch this thread at application level. 如果您有一个专门用于下载外部资源的线程,那么我将在应用程序级别启动该线程。 The thread shoudl report progress/completion/etc. 线程应该报告进度/完成情况等。 to an application level object and not to a specific page. 到应用程序级对象而不是特定页面。 The page shoudl query the app level object if it needs details to display. 页面应查询应用程序级对象是否需要显示详细信息。 This way the interactions between pages will have no effect and the data (eg download progress) will always be available to whatever page wants it. 这样,页面之间的交互将无效,并且数据(例如下载进度)将始终可用于任何需要它的页面。

The only time I may do this at a page level is if the app only contained a single page but then that's pretty much just the same thing. 我唯一可以在页面级别执行此操作的时间是,如果该应用程序仅包含一个页面,则几乎是同一回事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM