Поделиться через


DownloadProgress (Downloader)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets a value that indicates the relative progress of downloaded content.

value = downloaderObject.DownloadProgress

Property Value

Type: Double

A value between 0 and 1, inclusive, that represents the amount of total content that is downloaded. Multiply by 100 to obtain a percentage.

This property is read-only. The default value is 0.

Managed Equivalent

None. Downloader does not exist in the managed API. Generally you can use WebClient for downloads, which provides equivalent functionality.

Remarks

As soon as you invoke the Send method on the Downloader object, you can check the DownloadProgress property to determine the percentage of total content that has been downloaded. The return value is expressed as double value between 0 and 1.0, inclusive, with 0 representing no content downloaded, and 1.0 representing all content downloaded.

The DownloadProgressChanged event can be used monitor the progress of a download request. The DownloadProgressChanged event occurs whenever the percentage of total content that is downloaded increases by 0.05 or more, or reaches 1.0.

Example

The following JavaScript example shows how to use the DownloadProgress property in a DownloadProgressChanged event handler function.

// Event handler for updating visual progress indicator
function onDownloadProgressChanged(sender, eventArgs)
{
    // Calculate the downloaded percentage.
    var percentage = Math.floor(sender.downloadProgress * 100);

    // Update the Rectangle and TextBlock objects of the visual progress indicator.
    progressText.text = percentage + "%";
    progressRectangle.width = percentage * 2; 
}

A visual progress indicator can be constructed from a wide variety of XAML content, including animated objects.

Applies To

Downloader