public BitmapType FetchNowOrAsyncDownload(string url, int maxWidth, int maxHeight, Action <BitmapType> callback) { if (null != this.service) { ImageCachingService.OutBitmap instantResult = new ImageCachingService.OutBitmap(); this.service.DownloadImageAsync(url, maxWidth, maxHeight, callback, instantResult); return(instantResult.Bitmap); } pendingDownload.Add(new PendingDownload(url, maxWidth, maxHeight, callback)); DownloadNow(); return(null); }
protected void DownloadNow() { if (this.service == null) { return; } foreach (PendingDownload pending in pendingDownload) { ImageCachingService.OutBitmap instantResult = new ImageCachingService.OutBitmap(); this.service.DownloadImageAsync(pending.Url, pending.MaxWidth, pending.MaxHeight, pending.Callback, instantResult); if (null != instantResult.Bitmap) { pending.Callback(instantResult.Bitmap); } } }