इसके माध्यम से साझा किया गया


DownloadOperation.StartAsync Method

Definition

Starts an asynchronous download operation.

public:
 virtual IAsyncOperationWithProgress<DownloadOperation ^, DownloadOperation ^> ^ StartAsync() = StartAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperationWithProgress<DownloadOperation, DownloadOperation const&> StartAsync();
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperationWithProgress<DownloadOperation,DownloadOperation> StartAsync();
function startAsync()
Public Function StartAsync () As IAsyncOperationWithProgress(Of DownloadOperation, DownloadOperation)

Returns

An asynchronous download operation that includes progress updates.

Attributes

Remarks

Exceptions

COMException

Thrown when a feature-specific HRESULT is returned from a method call.

This is the most common exception that is thrown by networking methods. An app should use the HRESULT from the exception to determine the cause of the error.

AccessDeniedException

Thrown when access is denied to a resource or feature. This exception occurs when an app doesn't have the required network capabilities set in the app manifest for the network operation requested.

InvalidArgumentException

Thrown when one of the arguments that are provided to a method is not valid.

If user-supplied input caused this exception, an app could inform the user and request new input.

ObjectDisposedException

Thrown when an operation is performed on a disposed object.

OutOfMemoryException

Thrown when insufficient memory is available to complete the operation.

Background transfer doesn't support concurrent downloads of the same Uri. So an app can download http://example.com/myfile.wmv once, or download it again after a previous download completed. An app shouldn't start two downloads of the same Uri concurrently, since this may result in truncated files.

A download operation must be scheduled using one of the BackgroundDownloader.CreateDownload or BackgroundDownloader.CreateDownloadAsync methods before the StartAsync method is called.

Important

Queuing up a large number of transfers on the main UI thread can result in degraded performance of your app's UI, even though the call is awaitable. If you are queuing up a large number of transfers, it is recommended that you call StartAsync on a background worker thread as in the following example.

operation = await Task.Run(() => { return myDownloadOperation.StartAsync(); });

Applies to

See also