DownloadOperation.AttachAsync DownloadOperation.AttachAsync DownloadOperation.AttachAsync DownloadOperation.AttachAsync DownloadOperation.AttachAsync Method

Definition

Returns an asynchronous operation that can be used to monitor progress and completion of the attached download. Calling this method allows an app to attach download operations that were started in a previous app instance.

public : IAsyncOperationWithProgress<DownloadOperation, DownloadOperation> AttachAsync()
IAsyncOperationWithProgress<DownloadOperation, DownloadOperation> AttachAsync() const;
public IAsyncOperationWithProgress<DownloadOperation, DownloadOperation> AttachAsync()
Public Function AttachAsync() As IAsyncOperationWithProgress(Of DownloadOperationDownloadOperation)
Windows.Networking.BackgroundTransfer.DownloadOperation.attachAsync().done( /* Your success and error handlers */ );

Returns

Examples


        function AttachDownload (loadedDownload) {
            try {
                download = loadedDownload;
                promise = download.attachAsync().then(complete, error, progress);
            } catch (err) {
                displayException(err);
            }
        };

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. For more information on specific errors, see the Error Codes section below.

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.

While, this method can be called from multiple app instances, developers should not attach callbacks from the primary app instance in a background task. This will cause BackgroundTransferHost.exe to hang.