Skip to content

Latest commit

 

History

History
25 lines (15 loc) · 3.67 KB

windows_networking_backgroundtransfer.md

File metadata and controls

25 lines (15 loc) · 3.67 KB
-api-id -api-type
N:Windows.Networking.BackgroundTransfer
winrt namespace

Windows.Networking.BackgroundTransfer

-description

Enables advanced download and upload transfer capabilities within an app. For an overview of Background Transfer capabilities, see Transferring data in the background. Download the Background transfer sample for a code example.

Note

Background transfer is primarily designed for long-term transfer operations for resources like video, music, and large images. For short-term operations involving transfers of smaller resources (i.e. a couple KB), the HTTP APIs are recommended. HttpClient is preferred and can be used in all languages supported by UWP apps. XHR can be used in JavaScript. IXHR2 can be used in C++.

-remarks

On most platforms, Background Transfer will continue to transfer your files (download or upload) even when the app is suspended or when it exits. When your app starts up, you should call BackgroundDownloader.GetCurrentDownloadsAsync or BackgroundUploader.GetCurrentUploadsAsync to enumerate all of your incomplete transfers. Then call DownloadOperation.AttachAsync or UploadOperation.AttachAsync, respectively, on each one. Doing so retrieves the transfer's latest state and causes the transfers to be resumed after a system reboot. When DownloadOperation.IsRandomAccessRequired is true, the download resumes automatically after a reboot. You should call AttachAsync even in that case. If your app is running when the transfers complete (that is, when the call to AttachAsync returns), then you can do work in response. Alternatively, you can use BackgroundTransferCompletionGroup to launch a background task when the transfers complete.

On Xbox, Background Transfer only transfers your files (download or upload) while the app is in the foreground. When an app is either suspended, put into the background, or has exited, the app's background transfers are suspended. When the app runs in the foreground again, its transfers are resumed automatically.

-examples

-see-also

Adding support for networking, How to configure network isolation capabilities, Quickstart: Downloading a file, Quickstart: Uploading a file, Transferring a file from a network resource, Transferring data in the background, HttpClient, IXHR2, Windows.Storage, XHR, Background transfer sample, Background transfer sample (Windows 8.x)