Share via


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:
 virtual IAsyncOperationWithProgress<DownloadOperation ^, DownloadOperation ^> ^ AttachAsync() = AttachAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperationWithProgress<DownloadOperation, DownloadOperation const&> AttachAsync();
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperationWithProgress<DownloadOperation,DownloadOperation> AttachAsync();
function attachAsync()
Public Function AttachAsync () As IAsyncOperationWithProgress(Of DownloadOperation, DownloadOperation)

Returns

Download operation with callback.

Attributes

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.

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.

Applies to