예제 #1
0
        public void Load(object state)
        {
            while (true)
            {
                LoadThumbnailRequest request;
                lock (_syncLock)
                {
                    if (_pendingRequests.Count == 0)
                    {
                        _isLoading = false;
                        break;
                    }

                    request = _pendingRequests[0];
                    _pendingRequests.RemoveAt(0);
                }

                LoadThumbnailResult result;

                try
                {
                    var image = _repository.GetThumbnail(request.Descriptor, request.Size);
                    result = new LoadThumbnailResult(request.Descriptor, image, request.Size);
                }
                catch (Exception e)
                {
                    result = new LoadThumbnailResult(request.Descriptor, e);
                }

                request.ResultCallback(result);
            }
        }
예제 #2
0
 private void OnThumbnailLoadedAsync(LoadThumbnailResult result)
 {
     try
     {
         //Dispose the image on the thread on which the image was rendered because of some weirdities with current rendering implementation.
         result.Descriptor.ReferenceImage.Dispose();
         SynchronizationContext.Post(ignore => OnThumbnailLoaded(result), null);
     }
     catch (Exception e)
     {
         Platform.Log(LogLevel.Error, e);
     }
 }
예제 #3
0
 private void OnThumbnailLoaded(LoadThumbnailResult result)
 {
     //just toss it if it's not the size we are currently looking for, or we're disposed.
     if (result.Error == null && (result.Size != _thumbnailSize || _isDisposed))
     {
         if (result.ThumbnailData != null)
         {
             result.ThumbnailData.Dispose();
         }
     }
     else
     {
         ImageData     = result.ThumbnailData ?? Loader.GetErrorThumbnail(_thumbnailSize);
         _isImageValid = _isImageLoaded = true;
     }
 }