private async Task DownloadObjectAsyncImpl( string baseUri, Stream destination, DownloadObjectOptions options, CancellationToken cancellationToken, IProgress <IDownloadProgress> progress) { Preconditions.CheckNotNull(destination, nameof(destination)); var downloader = new MediaDownloader(Service); options?.ModifyDownloader(downloader); string uri = options == null ? baseUri : options.GetUri(baseUri); if (progress != null) { downloader.ProgressChanged += progress.Report; // Avoid reporting progress synchronously in the original call. await Task.Yield(); progress.Report(InitialDownloadProgress.Instance); } var result = await downloader.DownloadAsync(uri, destination, cancellationToken).ConfigureAwait(false); if (result.Status == DownloadStatus.Failed) { throw result.Exception; } }
private void DownloadObjectImpl( string baseUri, Stream destination, DownloadObjectOptions options, IProgress <IDownloadProgress> progress) { // URI will definitely not be null; that's constructed internally. Preconditions.CheckNotNull(destination, nameof(destination)); var downloader = new MediaDownloader(Service); options?.ModifyDownloader(downloader); string uri = options == null ? baseUri : options.GetUri(baseUri); if (progress != null) { downloader.ProgressChanged += progress.Report; progress.Report(InitialDownloadProgress.Instance); } var result = downloader.Download(uri, destination); if (result.Status == DownloadStatus.Failed) { throw result.Exception; } }