Windows Phone的后台8.1任务完成前关闭 [英] Windows Phone 8.1 background task closes before completion

查看:196
本文介绍了Windows Phone的后台8.1任务完成前关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的后台任务需要较长时间才能完成,操作系统只是杀死它。我想在网上同步我的联系人,这里是我在做什么:

My background task takes a long time to complete, and the OS is just killing it. I'm trying to sync my contacts online, here's what I'm doing:


  1. 获取从电话簿中的所有联系人(需要〜 1秒)

  1. Get all contacts from phonebook (takes ~1 second)

它们上传到服务器(〜2秒)

Upload them to a server (~2 seconds)

找回从服务器的所有联系人(〜2-3秒)

Retrieve all contacts from server (~2-3 seconds)

删除ContactStore的所有联系人(ContactStore.DeleteAsync有时需要1分钟才能完成)

Delete all contacts from ContactStore(ContactStore.DeleteAsync sometimes takes 1 minute to complete)

创建一个ContactStore的并导入所有联系人)(〜1-2分钟,1000个联系人)

Create a ContactStore and import all contacts )(~1-2 minutes for 1000 contacts)

我有100〜联系人和它的工作很好,但我想〜测试使用1000个联系人,并没有完成每一次。我使用的是MaintenanceTrigger,但我认为它仍然是太多的后台任务,但我需要为此进行确认。 MaintenanceTrigger任务应该被允许做更多的资源密集型的任务,那么,为什么OS杀死了我的后台任务?

I have ~100 contacts and it's working well, but I wanted to test with ~1000 contacts and it doesn't complete every time. I'm using a MaintenanceTrigger, but I think it's still too much for a background task, but I need a confirmation for this. MaintenanceTrigger tasks should be allowed to do more resource intensive tasks, so why is the OS killing my background task?

推荐答案

看看在此链接: https://开头msdn.microsoft.com/en-us/library/windows/apps/hh202942(v=vs.105).aspx

资源密集型任务被限制在10分钟的时间。

下面的约束必须在任务开始前得到满足。如果该设备不再符合这些限制代理将立即终止。

The following constraints must be met before the task is started. If the device stop fulfilling these constraints the agent is terminated immediately.


  • 需要外部电源

  • 非需要-cellular连接

  • 最小电池电量

  • 必需的设备屏幕锁

  • 没有有效的电话

  • 无法改变网络的蜂窝

  • External power required
  • Non-cellular connection required
  • Minimum battery power
  • Device screen lock required
  • No active phone call
  • Cannot change network to cellular

此外,这也有分别为11MB和20MB的内存上限低/高端设备。

Besides this there are also a memory cap of respectively 11mb and 20mb for low/high end devices.

从你的描述最有可能的情况上面IMO是内存上限被击中。也许这篇文章可以帮助你看看你的后台任务的内存使用情况:的如何获得可用的或C#使用的内存

From your description above the most likely scenario IMO is the memory cap being hit. Maybe this post can help you look into the memory usage of your background task: How to get memory available or used in C#

到内存限制在Windows Phone的8.1起重要变化包括(发现的这里):

Key changes to memory limits starting in Windows Phone 8.1 include (found here):


  • 所有的Windows Phone 8应用前景的待遇是一样的。我们不再有不同的内存上限为XNA,本地或Silverlight应用程序。

  • 的Windows Phone 8.1的应用程序(包括Silverlight的8.1和Windows运行时)的应用程序确实有比Windows Phone 8的应用程序略高帽

  • 内存上限为所有应用类型,包括连续后台执行(CBE),扩展增加内存。

  • 不再有一个默认和更高的帽子。 - 只有默认的上限

  • 的ID_FUNCCAP_EXTEND_MEM清单条目将被忽略在Windows Phone 8.1中运行的所有应用

  • 的ID_REQ_MEMORY_300清单条目仍然有效,但你应该真正使所有设备上您的应用程序运行。

  • ID_REQ_MEMORY_300的新的等效如下。此条目应被添加到AppX中清单(未给WMAppManifest)。

  • All Windows Phone 8 foreground apps are treated the same. We no longer have different memory caps for XNA, native or Silverlight apps.
  • Windows Phone 8.1 apps (including both Silverlight 8.1 and Windows Runtime) apps do have slightly higher caps than Windows Phone 8 apps.
  • Memory caps for all app types, including Continuous Background Execution (CBE), scale up with increased memory.
  • There is no longer a "default" and "higher" cap - there is only the default cap.
  • The ID_FUNCCAP_EXTEND_MEM manifest entry is ignored for all apps running on Windows Phone 8.1.
  • The ID_REQ_MEMORY_300 manifest entry is still valid, but you should really make your app run on all devices.
  • The new equivalent of ID_REQ_MEMORY_300 is below. This entry should be added to the AppX manifest (not to the WMAppManifest).

这篇关于Windows Phone的后台8.1任务完成前关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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