ImageDownloader
Handler for downloading images from the web. Single instance of the handler used for all images downloaded in a single html, this way if the html contains more than one reference to the same image it will be downloaded only once. Also handles corrupt, partial and canceled downloads by first downloading to temp file and only if successful moving to cached file location.
Implements: IDisposable
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
DownloadImage(Uri, DownloadFileAsyncCallback)
Makes a request to download the image from the server and raises the when it's down.
- imageUri
- The online image uri
- cachedFileCallback
- This callback will be called with local file path. If something went wrong in the download it will return null.
OnDownloadImageCompleted(string, Uri, byte[], Exception, bool)
Checks if the file was downloaded and raises the cachedFileCallback from _imageDownloadCallbacks
ReleaseObjects()
Release the image and client objects.
Fields
_imageDownloadCallbacks : Dictionary<Uri, List<DownloadFileAsyncCallback>>
dictionary of image cache path to callbacks of download to handle multiple requests to download the same image