Use the Windows.Networking.BackgroundTransfer APIs provided in the Windows Runtime to enhance your Windows Store app with advanced file download and upload features that run in the background during app suspension, demonstrate per operation lifecycle management, and persist beyond app termination.This feature is ideal for large file downloads and upload operations using the HTTP and HTTPS protocols. FTP is supported, but only when conducting download operations.
Background Transfer runs separate of the calling app and is primarily designed for long-term transfer operations for resources like video, music, and large images. In these scenarios, a Windows Store app can encounter periods of app suspension where the capability provided by Background Transfer to continue work in the background is beneficial. For more information on the Windows Store app lifecycle, review the Application lifecycle documentation.
Note When conducting short-term operations involving transfers of smaller resources (i.e. a couple KB), the use of provided HttpClient APIs.
When a Windows Store app uses Background Transfer to initiate a transfer, the request is configured and initialized using BackgroundDownloader or BackgroundUploader class objects. Each transfer operation is handled individually by the system and separate from the calling app. Progress information is available for display through an app UI, and depending on the scenario, you can enable the app to pause, resume, cancel, or even read from the data during transfer. The way transfers are handled by the system promotes smart power usage and prevents problems that can arise when a connected app encounters events like app suspension, termination, or sudden network status changes.
Watch this brief video for a demonstration of a simple file download using Background Transfer.
Background Transfer provides methods that support basic server and proxy credentials, cookies, and the use of custom HTTP headers (via SetRequestHeader) for each transfer operation.
The Background Transfer feature maintains a consistent experience for each transfer operation when network status changes occur by intelligently leveraging connectivity and carrier data-plan status information provided by the Connectivity feature. To define behavior for different network scenarios, an app sets a cost policy for each operation using values defined by BackgroundTransferCostPolicy.
For example, the cost policy defined for an operation can indicate that the operation should be paused automatically when the device is using a metered network. The transfer is then automatically resumed (or restarted) when a connection to an "unrestricted" network has been established. For more information on how networks are defined by cost, see NetworkCostType.
Note While the Background Transfer feature has its own mechanisms for handling network status changes, there are other general connectivity considerations for network-connected Windows Store apps. Read Leveraging available network connection information for additional info.
|Transferring a file from a network resource||
Add the capability to securely download and upload files to your Windows Store app.
|Background Transfer API reference||
API documentation for the entire Background Transfer Windows Runtime namespace.
|Background Transfer sample||
This sample demonstrates the power-friendly, cost-aware, and flexible behavior of the Background Transfer API for Windows Store apps.
Build date: 11/16/2013