Windows Phone proxy

Source: Internet
Author: User
Tags unsupported

For Windows Phone 8 | Windows Phone OS 7.1

 

The scheduling task and background proxy allow an application to execute code in the background even if it is not running in the foreground. Different types of scheduling tasks are designed for different types of background processing scenarios, and therefore have different behaviors and restrictions. This topic describes scheduling, duration, and limits.

This topic contains the following parts:

· Types of scheduled tasks

· Background proxy Lifecycle

· Restrictions on all types of scheduled tasks

· Periodic proxy restrictions

· Restrictions on centralized resource proxy

·Related Topics

Scheduled Task Type

Shape \ * mergeformat

The following lists the types of scheduled tasks. Note:ScheduledtaskYesfromScheduledactionDerived. The code running on the background is stored in the slaveScheduledtaskagentIn the derived class, andScheduledtaskagentIs from ClassBackgroundagentDerived.

 

Scheduled Task Type

Description

Periodictask

A periodic Agent runs for a short period of time every time it passes through a periodic cycle. Typical Cases of using this task include the location of the upload device and the execution of a small amount of data synchronization.

Resourceintensivetask

Resource-intensive proxy refers to the background proxy that needs to run for a relatively long period of time when the phone encounters a centralized requirement related to the processor activity, power supply, and network connection. A typical application of such tasks is that when the phone is not used by users but not active, a large amount of data is synchronized to the phone in the background.

Background proxy Lifecycle

Shape \ * mergeformat

An application may have only one background proxy. This proxy can be registered as a periodictask, A resourceintensivetask, or both. The scheduling algorithm used to run the agent depends on the type registered by the task. At a certain time point, only one proxy instance is running.

The proxy code is inBackgroundagentIn the derived class. The operating system will callOninvoke (scheduledtask)Method. In this method, the application can determine which type of scheduledtask is running and then perform the appropriate action. The contemporary manager has completed its task and it should callNotifycompleteOrAbortTo let the operating system know that it is finished. Yycomplete should be used after the task is successfully executed. If the agent cannot execute its tasks-for example, the required server cannot connect-then the agent should call abort, which causesIsscheduledProperty is set to false. The foreground application can check this attribute to determine whether abort is called in the background.

 

Restrictions on the types of scheduling tasks

Shape \ * mergeformat

The following constraints apply to all scheduled tasks.

 

Restrictions

Description

Unsupported APIs

Many APIs cannot be used by any scheduled task. Using these Apis does not throw an exception during running, but causes authentication failure when submitting applications to the store. To view restricted APIs, seeUnsupported APIs for background agents for Windows Phone.

Memory usage restrictions

Periodic proxy and resource-intensive proxy cannot use more than 6 MB of memory at any time. The audio proxy is limited to 15 MB. If a scheduled task exceeds the memory size, it will be terminated immediately.

When running in Debugger Mode, the restrictions on memory and timeout are temporarily canceled. You can useApplicationmemoryusagelimitAPI to query the memory limits of foreground applications and background proxies.

Reschedule every two weeks

UseScheduledtaskOfExpirationtimeAttribute to set how long the task scheduling will be stopped. When the action isAdd (scheduledaction)When the method is scheduled, This value must be set to less than two weeks. When an application associated with a task runs on the foreground, it may reschedule the task and set the running duration to two weeks from now on. There are many situations where the background proxy of an application will not stop or be reborn. If the tile of your application is fixed on the Start Screen, your background proxy will callUpdate (shelltiledata)When tile is updated, the lifecycle is automatically extended to two weeks. For more information, seeTiles for Windows Phone.

If your application is displayed on the screen, your background proxy will be called every timeUpdate (shelltiledata)Automatically extended to two weeks when the lock screen is updated. For more information, seeLock screen configurications for Windows Phone 8.

If your application uses a resource-intensive proxy to automatically upload images, If you enable this feature for your application on the image + camera settings page, the scheduling of this resource-intensive agent will never stop. For more information, seeAuto-upload apps for Windows Phone 8.

 

After two consecutive crashes, the agent stops scheduling.

Both periodic and resource-intensive proxies stop scheduling after they exit for two consecutive times because they exceed the memory quota or have any unhandled exceptions. The proxy can be rescheduled only when it passes through the foreground process.

Restrictions on periodic proxies

Shape \ * mergeformat

The following are the scheduling, duration, and general limitations of the agent.

Restrictions

Description

Scheduling interval: 30 minutes

The periodic agent generally runs every 30 minutes. To prolong the standby time, the periodic proxy may be adjusted to the running time connected to other background processes, so the execution time may fluctuate by 10 minutes.

Scheduling Duration: 25 seconds

The weekly proxy usually runs for 25 seconds. Other restrictions may lead to the early termination of a proxy.

The power-saving mode prevents execution.

Power-saving mode is an option that you can enable to prioritize power consumption. If this mode is enabled, the periodic proxy may no longer run even if the interval is exceeded.

Periodic proxy restrictions for each device

To maximize power savings, there is a hard rule on the number of periodic agents. This is different from the configuration of each device. The minimum value is 6. There is also a limit lower than the hard limit. After the limit is exceeded, the user is warned that multiple backend agents are running to quickly consume power.

Note:

If you want to add a periodic background proxy after the device limit is exceededAdd (scheduledaction)Will throw an invalidoperationexception. Because the number of periodic proxies for each device is too low, it is very easy for your application to encounter this problem. Therefore, it is very important to capture this exception when adding a periodic proxy so that your application will not crash. The sample code can be found hereBackground agent best practices for Windows Phone. Find.

 

Resource-intensive proxy restrictions

Shape \ * mergeformat

The following describes the scheduling, duration, and general limits of resource-intensive agents.

 

Restrictions

Description

Duration: 10 minutes

Resource-intensive agents generally only run for 10 minutes. There are other restrictions that may lead to the early termination of a proxy.

External Power supply required

Resource-intensive agents run only when the device is connected to an external power supply.

Non-cellular connection

Resource-intensive proxies run only when a Wi-Fi connection is established or a network connection is established through a connection to a PC.

Minimum power

Resource-intensive agents run only when the power of the device exceeds 90%.

Screen lock required

Resource-intensive agents run only when the screen is locked.

No call

Resource-intensive agents do not run when you call.

Cannot change network to cellular

If a resource-intensive proxy attempts to callAssociatetonetworkinterface (socket, networkinterfaceinfo)If mobilebroadbandgsm or mobilebroadbandcdma is specified, the call will fail.

If a device enters a status where all the preceding conditions are met and a resource-intensive agent starts to run, the status of the device changes and one of the conditions is no longer met, the resource-intensive proxy will be terminated immediately.

Note:

A resource-intensive agent can run only when all the conditions of the device are met. A proxy may never run on a certain device. For example, if a user is not connected to Wi-Fi or a PC, it will never get a non-cellular connection and the resource-intensive agent will never run. At the same time, only one resource-intensive proxy can be running, so when more applications use resource-intensive proxies, the hope of running a proxy is even more slim. You should carefully consider this issue when designing your application.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.