在后台将数据加载到WinJS.Binding.List中 [英] Load data into WinJS.Binding.List in background

查看:36
本文介绍了在后台将数据加载到WinJS.Binding.List中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个应用程序试图下载几千个图像并在分组列表视图中显示给用户。不幸的是,拥有这么多网络请求会对应用程序的启动时间产生严重的负面影响。我的解决方案是在启动时加载
前50个图像,并在使用应用程序时将其余图像加载到后台。因此,当前50个完成加载时,我调用一个异步函数,它加载其他图像并将它们推送到我的WinJS.Binding.List(
listView的数据源)。不幸的是,它没有直接进入应用页面并允许用户开始与应用程序交互,而是等待异步功能完成,这无助于减少启动时间。

I have an app which attempts to download a couple thousand images and display them to the user in a grouped listView. Unfortunately, having this many network requests has a severely negative effect on the app's launch time. My solution to this is to load the first 50 images on launch, and load the rest in the background as the app is being used. So, when the first 50 finish loading, I call an asynchronous function which loads the other images and pushes them on my WinJS.Binding.List (the data source for the listView). Unfortunately, instead of going straight to the app page and allowing the user to begin interacting with the app, it waits for the asynchronous function to complete, which doesn't help decrease the launch time at all.

如何启动后台进程来加载这些图像?

How can I start a background process to load these images?

推荐答案

在您激活的事件处理程序中,您传递的Promise表示将所有项目加载到"setPromise"的完成情况。事件args的功能?如果是这样,那么在考虑你的应用程序启动
之前,它就完成了对该承诺的阻止。

In your activated event handler are you passing the Promise representing the completion of loading all the items to the "setPromise" function of the event args? If so, it is blocking on that promise completing before considering your application to have started.

或者你可以考虑为VirtualizedDataSource实现一个数据适配器(http://msdn.microsoft.com/en-us/library/windows/apps/hh701413.aspx)根据需要在数据中寻找

Alternatively you could consider implementing a data adapter for the VirtualizedDataSource (http://msdn.microsoft.com/en-us/library/windows/apps/hh701413.aspx) which would page in data as needed.

-josh


这篇关于在后台将数据加载到WinJS.Binding.List中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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