Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of the Downloader object in Silverlight

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the use of Downloader objects in Silverlight. It is very detailed and has a certain reference value. Friends who are interested must finish reading it.

There is a Downloader object in Silverlight that can be used to download the corresponding files in Silverlight applications, such as scripts, media files, and so on. With it, you can download the corresponding files according to the specific needs of the application, without having to download all the files needed by the entire application when the Silverlight plug-in is initialized. This not only saves the waiting time for users to download the application, but also allows the downloaded content to be used dynamically in the application without having to refresh the entire page.

The Downloader object can initialize data transfer, monitor the process of data transfer, and easily get the downloaded files. The implementation of the progress bar when loading an application requires the power of the object Downloader. In addition, the Downloader object can be used to download the ZIP package and get a single file from the downloaded ZIP package.

To use the Downloader object, first create an object instance of Downloader in the Silverlight plug-in using the CreateObject method of Silverlight. There are several common methods in Downloader:

The ◆ Open method is used to instantiate the Downloader object and to specify what to download. This method contains two parameters of type string: * parameters that specify the download behavior, which currently only supports "GET"; and the second parameter is a URI that indicates the downloaded file.

The ◆ Send method is used to execute the download request. This method does not contain any parameters and downloads the file asynchronously.

Because Downloader objects download files asynchronously, operations on downloaded files are generally performed through event-triggered methods. You can use the addEventListener method to add event listeners to an object instance of Downloader. The addEventListener method contains two parameters: the * parameter indicates the Downloader event to listen for, and the second parameter indicates the name of the method to handle the event. The Downloader object has a total of three events:

The ◆ Completed event fires when the download request completes and the download content is returned.

The ◆ DownloadFailed event returns when the download fails.

The ◆ DownloadProgressChanged event is triggered during download.

An example of using a Downloader object is as follows:

Function onDemandLoaded (sender, eventArgs). {/ / first get a reference to the current Silverlight plug-in var SilverlightPlugin = sender.getHost (); / / create a Downloader object var downloader = SilverlightPlugin.createObject ("downloader"); / / initialize the Downloader object downloader.open ("GET", "myPage.xaml"); / / execute the download request downloader.send (); / / add event listening downloader.addEventListener ("downloadProgressChanged", onDownloadProgressChanged) Downloader.addEventListener ("completed", onCompleted);} function onDownloadProgressChanged (sender, eventArgs). {/ / sender returns the downloaded file object} function onCompleted (sender, eventArgs). {} above is all the content of the article "what is the use of Downloader objects in Silverlight?" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report