Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: Using async/await to prevent MagickCacheErrorException

$
0
0
I have tried for each image in the listbox to do
private void ExtractThumbnail()
{
  Task.Factory.StartNew(() =>
  {
    using (MagickImage image = new MagickImage(fullPath))
    {
        image.Thumbnail(0, 100);
        ImageSource mythumb = loadBitmap(image.ToBitmap());
        if (mythumb.CanFreeze) mythumb.Freeze();
        Thumbnail = mythumb;
    }
but that leads to ImageMagick.MagickCacheErrorException.

Without Task.Factory it does not give me the error but UI is completely unreponsive until all images are there.

If I don't use Taks.Factory and set
<Image Source="{Binding Thumbnail, IsAsync=True}"
then I get the error again

Is there a way to use async/await on the line
using (MagickImage image = new MagickImage(fullPath))
or some other way to prevent the error and get all thumbnails?

Viewing all articles
Browse latest Browse all 3693

Trending Articles